GNU make builtin rules produce linker error due to command line arguments order
Robrecht Dewaele
rdewaele@vub.ac.be
Tue Apr 6 23:24:00 GMT 2010
Hello everyone,
I'm not sure whether this is a make or a cygwin issue, but it has
occured to me only on cygwin, so I thought to ask here first.
To illustrate my problem, I have written a little testcase (options.c)
which uses libpopt and illustrate how to reproduce the behaviour at the
bottom of this message.
I think the basic issue here is that the linker only resolves symbols in
files in the order as they appear on the command line.
This is afaik not an erroneous behaviour, but it doesn't play well with
the builtin make rules as shown below.
This test was run using a fresh cygwin install from today, on a windows
XP host.
The account I'm using is an administrator account.
##### Version of the make and cc programs.
$ cc --version => cc (GCC) 4.3.4 20090804 (release) 1
$ make --version => GNU Make 3.81
##### Only the C source file is present, and it uses libpopt.
$ ls
options.c
##### Using builtin make rules and LDFLAGS seems to yield an incorrect
order of arguments for cc.
$ LDFLAGS=-lpopt make options
cc -lpopt options.c -o options
/tmp/ccW0jXSk.o:options.c:(.text+0x3e): undefined reference to
`_poptGetContext'
/tmp/ccW0jXSk.o:options.c:(.text+0x56): undefined reference to
`_poptGetNextOpt'
/tmp/ccW0jXSk.o:options.c:(.text+0x78): undefined reference to
`_poptBadOption'
/tmp/ccW0jXSk.o:options.c:(.text+0x85): undefined reference to
`_poptStrerror'
/tmp/ccW0jXSk.o:options.c:(.text+0xb8): undefined reference to
`_poptPrintHelp'
/tmp/ccW0jXSk.o:options.c:(.text+0xfa): undefined reference to
`_poptFreeContext'
/tmp/ccW0jXSk.o:options.c:(.data+0x68): undefined reference to
`_poptHelpOptions'
collect2: ld returned 1 exit status
make: *** [options] Error 1
##### When '-lpopt' is positioned after the source file, no linker
errors appear.
$ cc options.c -lpopt -o options
(no output)
##### And a working executable is produced.
$ ./options.exe -t
test option set!
Kind regards,
Robrecht
-------------- next part --------------
A non-text attachment was scrubbed...
Name: options.c
Type: text/x-csrc
Size: 826 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20100406/fc580f80/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out.txt
URL: <http://cygwin.com/pipermail/cygwin/attachments/20100406/fc580f80/attachment.txt>
-------------- next part --------------
--
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