Problem with static library linking
Eljay Love-Jensen
eljay@adobe.com
Mon Mar 24 13:00:00 GMT 2008
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
More information about the Gcc-help
mailing list