gcc 4.2.3/popt 1.13 error message - google is no help...
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
gcc 4.2.3/popt 1.13 error message - google is no help...
Hi there, let me start out by saying I'm not sure if this question belongs in Programming, or Software, I'm winging it in programming and won't be too offended if I get kicked in the teeth if I'm wrong. Now on to my question:
I'm developing a small command line application that will require some command line arguments. I'm writing this in C (my first program in C) and learned of the popt library. I read the man pages, studied the examples, etc. I set up some code to start configuring my popt configuration and when I get to the point where I call poptGetContext gcc returns an error "warning: passing argument 3 of ‘poptGetContext’ from incompatible pointer type" I've googled this several times, and apparently its a pretty common issue, but no one has posted an answer. The best I've found so far is one person stating the popt.h has an incorrect configuration.
I'm writing this app on Gentoo, with gcc 4.2.3, and popt 1.13. I've defined main as "
Code:
int main (int argc, char** argv)
", and my popt call look like this so far:
Code:
struct poptOption vcla[]={ /*Valid Command Line Arguments*/
{"block-size",'b',POPT_ARG_STRING,&block_size,0,"how much data should we copy at once","[B|K|M|G]"},
{"delay",'d',POPT_ARG_STRING,&wait_time,0,"how much delay should we include between each block we copy","[S|M|H]"},
{"verbose",'v',0,0,'v',"verbose output",""},
/*POPT_AUTOHELP*/
{ NULL, 0, 0, NULL, 0 }
};
poptContext rcla = poptGetContext(NULL, argc, argv, vcla, 0);
my gcc command looks like this:
gcc -D DEBUG -D_FILE_OFFSET_BITS=64 -march=prescott -pipe -fomit-frame-pointer -O2 slcp.c -o slcp
and finally, the definition in popt.h for the function in question is this:
(as a side note, do the comments sprinkled throughout this code have any effect?)
any help would be greatly appreciated. A solution will make you my hero for a day. It's a pain having to hard code the new parameters in that should just be provided at the command line.
FYI(1)--the deom app in the man page thows the same error as my app.
FYI(2)--the app I'm writing is called slcp, it allows you to copy a file slowly instead of going as fast as the machine can muster. I'm using it to pull data off a RAID5 array that is running on a crappy card (vendor shall remain unnamed to protect them from their own stupidity.) It's worked quite well allowing me to save a 150GB VMWare virtual hard drive so far if you'd like the source code please contact me, I'm happy to share.
I set up some code to start configuring my popt configuration and when I get to the point where I call poptGetContext gcc returns an error "warning: passing argument 3 of ‘poptGetContext’ from incompatible pointer type" I've googled this several times, and apparently its a pretty common issue, but no one has posted an answer. The best I've found so far is one person stating the popt.h has an incorrect configuration.
First, this is only a warning. Many perfectly nice pieces of code throw warnings on some compiler or another because of some technicality. Also, there are instances where a warning-free code is harder to understand than its warning-full counterpart.
In your case, argv has type char**, but the third argument of the function expects a type const char**. So to get rid of the error, you can change the definition of argv to be const-qualified (if you do not intend to modify the contents) as Guttorm pointed out, or you can simply cast to const in the function call:
Thanks guys, that helped get rid of that warning, now I've got a new error that I've seen reported in relation to using popt as well.
Code:
slcp.c: (.text+0x119): undefined reference to `poptGetContext'
I think if I can get a resolution to this I might be good to go. why would the function be an undefined reference when it's clearly in the header file? I've un-installed and re-installed popt to verify that it's not a corrupt install. I recognize the error references the .text section of the generated assembler code, with an offset, but why would it reference .text on an executable portion of code?
Thanks again for all the help, I've been beating my head against a wall with this for a couple of days now.
Thanks guys, that helped get rid of that warning, now I've got a new error that I've seen reported in relation to using popt as well.
Code:
slcp.c: (.text+0x119): undefined reference to `poptGetContext'
This is a linker error (and not a compiler error). Did you specify ‘-lpopt’ at the command for creating the executable? If you are using the same command as in your first post, change it to:
Thanks for all the help, that cleared everything up, no more error messages are being reported. Thanks again for the education, this is quite a bit different than my Pascal/Delphi/VB/PHP development.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.