Important: Please read the Qt Code of Conduct -

How to link statically with Boost libraries in Qt Creator?

  • Hi all. I am doing an application which makes use of Boost libraries.

    I have Boost libraries complied both with the static (.lib) and the dynamic (.dll) versions (1.55).

    My .pro file (should) includes a Boost library statically as follows:

    unix|win32: LIBS += -L$$PWD/'../../../../../Program Files/boost_1_55_0/stage/x86/lib/' -lboost_thread-vc140-mt-gd-1_55
    INCLUDEPATH += $$PWD/../../../../../Boost/include/boost-1_55
    DEPENDPATH += $$PWD/../../../../../Boost/include/boost-1_55
    win32:!win32-g++: PRE_TARGETDEPS += $$PWD/'../../../../../Program Files/boost_1_55_0/stage/x86/lib/boost_thread-vc140-mt-gd-1_55.lib'
    else:unix|win32-g++: PRE_TARGETDEPS += $$PWD/'../../../../../Program Files/boost_1_55_0/stage/x86/lib/libboost_thread-vc140-mt-gd-1_55.a'

    The above is an example with Boost thread. The other is Boost system. Everything goes fine, but when it comes to run my executable outside Qt Creator it asks for boost .dlls. How is it possible? When I add those .dll in the directory everything goes fine.

    Note, furthermore, that windeployqt.exe does not load those boost .dll. Adding CONFIG += static or CONFIG += staticlib still does not resolve.

    Qt version: 5.11.1
    OS: Windows 10
    C++ compiler (Qt and Boost): MSVC 2015 x86

  • Lifetime Qt Champion


    .lib files on Windows can either be import libraries or static libraries. Are you sure yours are static libraries ?

Log in to reply