|
| | Subject: | Re: Problem with static library linking | | Group: | Gcc-help | | From: | Eljay Love-Jensen | | Date: | 24 Mar 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
|