argp - Missing initializer and _argp_parse undefined reference

Corinna Vinschen corinna-cygwin@cygwin.com
Sat Mar 17 11:27:00 GMT 2012


On Mar 16 21:08, John Wicks wrote:
> Trying to include argp from Shulman's new package but using the
> example code produces a couple errors.
> 
> The first one is missing initializers in the argp structure
> 
> socket1.c:12:15: warning: missing initializer
> socket1.c:12:15: warning: (near initialization for ‘argp.children’)
> 
> 12: static struct argp argp = {0,0,0,doc};
> 
> I was able to fix that by checking the definition of the structure and
> setting the other three arguments to 0 as well.
> 
> 12: static struct argp argp = {0,0,0,doc,0,0,0};
> 
> The last error after fixing the above is:
> 
> $ gcc -Wall -Wextra -pedantic -o socket1 socket1.c
> /tmp/ccdeH74x.o:socket1.c:(.text+0x45): undefined reference to `_argp_parse'
> collect2: ld returned 1 exit status
> 
> cygcheck -l produces the following:
> $ cygcheck -l libargp
> /usr/bin/cygargp-0.dll
> /usr/include/argp.h
> /usr/lib/libargp.dll.a
> /usr/lib/libargp.la
> 
> Usually the undefined reference means I'm not including the library.
> Do I have to explicitly include -libargp ?

Of course.  How should gcc know what library you want to link against?
It's just -largp, not -libargp (== option -l with library name without
the leading "lib" and without the trailing ".a".


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list