Static lib + static libs
-
wrote on 15 Mar 2011, 20:59 last edited by
Hi. I am creating a static lib (A) using Qt Creator and this static lib links against other static libs (B) and then I have another program that is linking against my main static lib (A) however I am getting "symbol(s) not found" errors unless I also link in the (B) libs. Shouldn't my (B) libs be linked into my (A) lib and my program should not require the additional links? This is working for me using XCode on OSX but maybe Qt Creator handles this differently?
Any advice is greatly appreciated.
Thanks.
-=ben
Moved to C++ as it's not a Qt issue
-
wrote on 15 Mar 2011, 21:07 last edited by
A static library is only a collection ob objects. They are resolved when linked to a binary.
You can't link a static lib agains dlls or other libs.It's always the responsibility of the binary to get all object code together, this includes static libraries.
-
wrote on 15 Mar 2011, 21:15 last edited by
Are there any utils for combining libs into a single lib for osx as well as windows?
Thanks.
-=ben
-
wrote on 15 Mar 2011, 21:22 last edited by
The only possibility is to explicitly incorporate the symbols of lib B into lib A. This does not work by just linking B to A, one has to use some library tools (eg. using ar on unix/linux systems). Maybe XCode does that magic automatically for you, whereas qmake with regular Makefiles does not.
-
wrote on 16 Mar 2011, 08:16 last edited by
marswith: That tool is called ar. Mac, Linux and windows use this really simplistic packaging tool to store a set of object files into a static library. Of course all OSes use slightly different formats in the ar files they call static libraries;-)
1/5