Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Building a static library using Qt that statically links a 3rd party library



  • ...but even though I explicitly use the 3rd party library and have added it to the static library via LIBS += /3rd/party/library.lib - when I build the client application (a test application that uses my static library) all of the 3rd party symbols are failing to resolve unless I add "LIBS += /3rd/party/library.lib" to the client application.

    This behavior happens in Qt Creator - but presumably is entirely qmake oriented.

    This doesn't happen when I build my static library (that uses Qt) in Visual Studio - the client application only has to link to my static library and everything works well.

    BTW, the same is true for the Qt libraries as well.

    If I build my static library using Visual Studio, my client application doesn't have to link to any Qt libraries in order to build properly.

    If I build my static library using Qt Creator, my client application has to be explicitly linked to Qt libraries (like Core and Network.)

    Any suggestions?



  • I forgot to mention, I'm using -whole-archive on the LIBS += commands.
    It seems like for static libs, qmake ignore LIBS commands entirely.



  • If I hand edit the Makefile produced by QMAKE, I see that the LIBFLAGS entry is empty, so if I manually add:

    LIBFLAGS      = my3rdparty.lib
    

    QtCreator builds the library as I was hoping, and the client application links and runs and passes all unit tests.

    I presume that QMAKE_LFLAGS is supposed to influence that entry, but it does nothing...

    Help?


  • Lifetime Qt Champion

    Hi,

    Can you show the content of your .pro file ?
    What version of Qt are you using ?


Log in to reply