Re: Problem with static library linking

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

 



Hi Harish,

> In my link line libpcap.a comes before mylib.a

Since mylib.a depends on libpcap.a, mylib.a should come before libpcap.a on
your link line.

Otherwise, unfulfilled symbols in mylib.a won't be found because libpcap.a
had already been processed.

Order of archives on the link line is significant.

If you have circular dependencies in your archive libraries (ugh! Avoid if
possible!), you can do:

gcc -o myapp \
 foo.c \
 alpha.a \
 beta.a \
 alpha.a

...or on many platforms that use GNU ld...:

gcc -o myapp \
 foo.c \
 --Wl,--whole-archive \
   alpha.a beta.a \
 --Wl,--no-whole-archive

HTH,
--Eljay


[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