Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Static lib + static libs

    C++ Gurus
    4
    5
    3593
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mirswith 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

      1 Reply Last reply Reply Quote 0
      • G
        giesbert 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.

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply Reply Quote 0
        • M
          mirswith last edited by

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

          Thanks.

          -=ben

          1 Reply Last reply Reply Quote 0
          • G
            goetz 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.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply Reply Quote 0
            • T
              tobias.hunger 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 Reply Last reply Reply Quote 0
              • First post
                Last post