On Oct 22, 2007, at 5:07 PM, Hongliang Wang wrote:
Hello, all.I built two libraries in two directories (gen and ora) respectively and now are building the executable program in "util" directory linked against the previous libraries. However, errors arise when compling.[EMAIL PROTECTED]> make make all-recursive make[1]: Entering directory `/export/guam/jigsaw/dev/jhwgu/src/jz' Making all in gen make[2]: Entering directory `/export/guam/jigsaw/dev/jhwgu/src/jz/gen' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/export/guam/jigsaw/dev/jhwgu/src/jz/gen' Making all in ora make[2]: Entering directory `/export/guam/jigsaw/dev/jhwgu/src/jz/ora' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/export/guam/jigsaw/dev/jhwgu/src/jz/ora' Making all in utilmake[2]: Entering directory `/export/guam/jigsaw/dev/jhwgu/src/jz/ util' gcc -g -O2 -o zizzy -ggdb `pkg-config --libs glib-2.0` zizzy- main.o zizzy-dictionary.o zizzy-dump.o zizzy-zop.o ../gen/ libzizzy.a ../ora/libzizora.a -lm ../ora/libzizora.a(zizoraread.o)(.text+0x50): In function `ZOraLogFileClose': /home/jigsaw/dev/jhwgu/src/jz/ora/zizoraread.c:197: undefined reference to `ZFClose'
[more undefined references]Your undefined references come from the libzizora.a, are you sure you're linking the libraries in the right order? The most dependent libraries have to go first. So if, say, libzizora.a use things from libzizzy.a, it must appear beforehand on the link command. If the problem is not related to linking order, then can you tell us where are defined the various missing symbols?
collect2: ld returned 1 exit status make[2]: *** [zizzy] Error 1 make[2]: Leaving directory `/export/guam/jigsaw/dev/jhwgu/src/jz/util' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/export/guam/jigsaw/dev/jhwgu/src/jz' make: *** [all] Error 2 This is my Makefile.am in util---------------------------------------------------------------------- ----------# util/Makefile.am bin_PROGRAMS = zizzyzizzy_SOURCES = main.c dictionary.c dictionary.h dump.c dump.h zop.c zop.h hl.envzizzy_LDADD = ../gen/libzizzy.a ../ora/libzizora.a zizzy_CFLAGS = -Wall -Werror `pkg-config --cflags glib-2.0` zizzy_LDFLAGS = -ggdb `pkg-config --libs glib-2.0` INCLUDES = -I..
[SNIP]
So I have two questions:1, why cannot I see zizzy_CFLAGS in the output message? I can only find zizzy_LDFLAGS.
Because `CFLAGS' means ``Compilation FLAGS'' and as such they do not need to be used when linking. So they're not used when linking. Similarily, `LDFLAGS' aren't used during the compilation, they're only passed to the ``Link eDitor'' (I guess that's where `LD' comes from).
2, why does the compiler trying to re-compile the library file (gen/ libzizzy.a ora/libzizora.a), but not to use them directly?
I don't see where it's trying to re-compile the library. -- Benoit Sigoure aka Tsuna EPITA Research and Development Laboratory
PGP.sig
Description: This is a digitally signed message part