Re: The order of arguments differs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok more information :

First computer :
$ xml2-config --cflags --libs --version
-I/.../software/libxml2-2.7.8/include/libxml2
-L/.../software/libxml2-2.7.8/lib -lxml2 -lz -lm
2.7.8

Second computer :
$ xml2-config --cflags --libs --version
-I/.../software/libxml2-2.7.8/include/libxml2
-L/.../software/libxml2-2.7.8/lib -lxml2 -lm
2.7.8

As you can see, this is the same version of the library used.

When I compile I do :

First computer :
$ autoreconf
$ make
Making all in src
make[1]: Entering directory `/.../1-xmlParseFile/src'
gcc -DPACKAGE_NAME=\"xmlparsefile\" -DPACKAGE_TARNAME=\"xmlparsefile\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"xmlparsefile\ 0.1\" -DPACKAGE_BUGREPORT=\"...\" -DPACKAGE_URL=\"\" -DPACKAGE=\"xmlparsefile\" -DVERSION=\"0.1\" -I.    -Wall -Wextra `xml2-config --cflags` -g -O2 -MT xmlparsefile-main.o -MD -MP -MF .deps/xmlparsefile-main.Tpo -c -o xmlparsefile-main.o `test -f 'main.c' || echo './'`main.c
mv -f .deps/xmlparsefile-main.Tpo .deps/xmlparsefile-main.Po
gcc -Wall -Wextra `xml2-config --cflags` -g -O2 `xml2-config --libs`  -o xmlparsefile xmlparsefile-main.o
make[1]: Leaving directory `/.../1-xmlParseFile/src'
make[1]: Entering directory `/.../1-xmlParseFile'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/.../1-xmlParseFile

Second computer :
$ autoreconf
$ make
Making all in src
make[1]: Entering directory `/.../1-xmlParseFile/src'
gcc -DPACKAGE_NAME=\"xmlparsefile\" -DPACKAGE_TARNAME=\"xmlparsefile\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"xmlparsefile\ 0.1\" -DPACKAGE_BUGREPORT=\"...\" -DPACKAGE_URL=\"\" -DPACKAGE=\"xmlparsefile\" -DVERSION=\"0.1\" -I.    -Wall -Wextra `xml2-config --cflags` -g -O2 -MT xmlparsefile-main.o -MD -MP -MF .deps/xmlparsefile-main.Tpo -c -o xmlparsefile-main.o `test -f 'main.c' || echo './'`main.c
mv -f .deps/xmlparsefile-main.Tpo .deps/xmlparsefile-main.Po
gcc -Wall -Wextra `xml2-config --cflags` -g -O2 `xml2-config --libs`  -o xmlparsefile xmlparsefile-main.o
xmlparsefile-main.o: In function `parseDoc':
main.c:(.text+0xd): undefined reference to `xmlParseFile'
main.c:(.text+0x51): undefined reference to `xmlParseFile'
main.c:(.text+0x63): undefined reference to `xmlParseFile'
main.c:(.text+0x68): undefined reference to `xmlParseFile'
collect2: ld returned 1 exist status
...

And now, the Makefile.am on each computer :
bin_PROGRAMS = xmlparsefile
xmlparsefile_SOURCES = main.c
xmlparsefile_LDFLAGS = `xml2-config --libs`
xmlparsefile_CFLAGS = -Wall -Wextra `xml2-config --cflags`

Do you understand why I got this error on one computer, and not on the other?

----- Mail original -----
De: "Ian Lance Taylor" <iant@xxxxxxxxxx>
À: "spam spam spam spam" <spam.spam.spam.spam@xxxxxxx>
Cc: gcc-help@xxxxxxxxxxx
Envoyé: Vendredi 17 Février 2012 16:30:40
Objet: Re: The order of arguments differs

spam.spam.spam.spam@xxxxxxx writes:

> I have just compiled libxml2 the same way on the two computers :
> ./configure --prefix=...
> make
> make install
>
> On the first computer, I got the compile problem.
> On the second computer, I got no problem when compile.
>
> So, I think the problem is about gcc on the first computer.
>
> What should I do to compile fine my program with gcc on both computers?

Sounds like you have a different set of libraries installed on both
computers.

If you want a better answer, you'll need to give us more information.

In general it is certainly true that the order of -L and -l arguments on
the gcc command line matters.  The documentation is clear on this.

    You can mix options and other arguments.  For the most part, the
    order you use doesn't matter.  Order does matter when you use
    several options of the same kind; for example, if you specify '-L'
    more than once, the directories are searched in the order specified.
    Also, the placement of the '-l' option is significant.

Ian



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux