This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The order of arguments differs


On the first computer, I recompile libxml2 "dynamically" :
./configure --prefix=/.../software/libxml2-2.7.8 --disable-static
make
make install

now :
$ xml2-config --libs
-L/.../software/libxml2-2.7.8/lib -lxml2 -lm
$ xml2-config --cflags
-I/.../software/libxml2-2.7.8/include/libxml2
$ ls /.../software/libxml2-2.7.8/lib
libxml2.la
libxml2.so
libxml2.so.2
libxml2.so.2.7.8
pkgconfig
xml2Conf.h

But always the same problem :
$ gcc `xml2-config --libs` `xml2-config --cflags` src/main.c
/tmp/ccXlXfPu.o: In function `parseDoc':
...

I try with the -Wl and -t :
$ gcc -Wall -Wextra `xml2-config --cflags`  `xml2-config --libs` -Wl -t  -o xmlparsefile xmlparsefile-main.o
/usr/bin/ld: mode elf_i386
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crti.o
/usr/lib/gcc/i686-linux-gnu/4.6.1/crtbegin.o
-lxml2 (/auto/pierre/software/libxml2-2.7.8/lib/libxml2.so)
-lm (/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/libm.so)
xmlparsefile-main.o
-lgcc_s (/usr/lib/gcc/i686-linux-gnu/4.6.1/libgcc_s.so)
/lib/i386-linux-gnu/libc.so.6
(/usr/lib/i386-linux-gnu/libc_nonshared.a)elf-init.oS
/lib/i386-linux-gnu/ld-linux.so.2
-lgcc_s (/usr/lib/gcc/i686-linux-gnu/4.6.1/libgcc_s.so)
/usr/lib/gcc/i686-linux-gnu/4.6.1/crtend.o
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crtn.o
xmlparsefile-main.o: In function `parseDoc':
main.c:(.text+0xd): undefined reference to `xmlParseFile'
main.c:(.text+0x51): undefined reference to `xmlCleanupParser'
main.c:(.text+0x63): undefined reference to `xmlFreeDoc'
main.c:(.text+0x68): undefined reference to `xmlCleanupParser'
/usr/bin/ld: link errors found, deleting executable `xmlparsefile'
collect2: ld returned 1 exit status

The order was automatically determined by my autotools (autoconf and automake).
I think there are in the good order.

Do you have any other idea to resolve this problem?

Thank you.

----- Mail original -----
De: "Ryan Mansfield" <rmansfield@qnx.com>
Ã: gcc-help@gcc.gnu.org
EnvoyÃ: Mercredi 15 FÃvrier 2012 15:49:04
Objet: Re: The order of arguments differs

On 12-02-15 09:41 AM, spam.spam.spam.spam@free.fr wrote:
> Hello,
>
> I am compiling a program on 2 computers.
>
> Table of contents
> 1. First computer
> 2. Second computer
> 3. Conclusion
>
> 1. First computer
>
> $ gcc src/main.c `xml2-config --libs` `xml2-config --cflags`
>
> Now with a different order of arguments :
> $ gcc `xml2-config --libs` `xml2-config --cflags` src/main.c
> /tmp/ccXlXfPu.o: In function `parseDoc':

> 3. Conclusion
>
> It's a big problem to have a different behaviour on each computer.

You're likely linking statically against libxml2 on the first computer,
and dynamically on the second. Check with -Wl,-t. Link order matters
when statically linking; the reference always has to come before the
symbol definition (unless you use -start-group/--end-group to have ld
make a second pass)

> Do you think it's a gcc problem?

No.

Regards,

Ryan Mansfield


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]