linking problems with several static libraries

linking problems with several static libraries

Diego Iastrubni elcuco at kde.org
Wed Jul 10 21:31:51 IDT 2013


Hi all,

I have been figthing this nice problem at work, which I would like someone to 
help me. Basically, I have several static libs (liba... libk) which I need to 
link to my program.

My program needs liba, which in turn needs libb.. which in turn needs libk. 
The last libk needs symbols from liba.. and this is where it gets funky. While 
linking g++ complains that symbols are missing ... and from ar+nm I see that 
those symbols are avarilable on liba.

My solution was to 

g++ -o blabla $(OBJS) liba.a libb.a l...libk.a liba.a

I know that using -L -l does not work as well, at I do need to link liba.a 
twice. 

I can reproduce this on Ubuntu 10.04 64bit (default toolchain, gcc 4.6) and in 
Android's NDK (using all availble toolchains 4.4.3, 4.6 and clang 3.2).

Can anyone explain why am I seeing this problem?

- diego



More information about the Linux-il mailing list