Static lib + static libs



  • 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



  • 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.



  • Are there any utils for combining libs into a single lib for osx as well as windows?

    Thanks.

    -=ben



  • 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.


  • Moderators

    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;-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.