Important: Please read the Qt Code of Conduct -

Boost + Qt installation problem (cannot find -lboost_system)

  • Ok currently having a problem using boost with Qt.

    Boost was built as complete, so contains all the files needed to work (.a,dll.a,dll)
    Alt text

    As you can see it contains lots of liboost system libraries. All with the correct build version (built using QT creators mingw version - 491_32.

    Inside my .pro file i've included the locations of the boost folder along with the library location.

    QT       += core
    QT       -= gui widget
    TARGET = Testing_Exif
    CONFIG   += console
    CONFIG   -= app_bundle
    INCLUDEPATH += C:\releases\lib\boost\Qt\boost_1_58_0
    LIBS += -LC:\releases\lib\boost\Qt\boost_1_58_0\stage\lib\ \
    TEMPLATE = app
    SOURCES += main.cpp \
    HEADERS +=  EXIF.h

    Compiler Output listed below:

    C:/Qt/Qt5.4.1/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lboost_system
    collect2.exe: error: ld returned 1 exit status
    Makefile.Debug:80: recipe for target 'debug\Testing_Exif.exe' failed
    mingw32-make[1]: *** [debug\Testing_Exif.exe] Error 1

    As you can imagine not really sure where to go from here, as have to use boost no matter what.

    For a test example I have created a single very basic file that just contains:

    QCoreApplication a(argc, argv);
    const boost::filesystem::path inputFileName = "C:\\Users\\Nick.CSM3D\\Documents\\Qt\\Testing_Exif\\ROOS_JUDY_RT.jpeg";
    return a.exec();

    Environment Paths:

    Anyone has a clue why I am not able to add -lboost_system (whether that be using its direct name, well one of them, or the name listed to the left). If anyone has an idea where I am going wrong that would be great.

    If anyone has an idea where I should go from here that would be great

  • The problem is that LIBS += -lboost_system tries to link a library named libboost_system.<version>.dll.

    In your case you have the platform naming mgw49 that differs from what the linker expect.
    You can either:

    • rebuild boost without platform information (IIRC there's a flag to do this but I don't remember exactly the name)
    • add the platform information to the LIBS like LIBS += =lboost_system-mgw49-mt-1_58

    UPDATE: The flag to control the library naming should be --layout. To remove compilers, tools in the library name you should use --layout=system

  • Ah thanks for the help mcosta that was it, didn't realise that i still had to use "-lboost" instead of "-libboost". Is there any reason why they aren't the same as the filename itself ?

    Also cheers for layout stuff should make my life easier for later.

  • Hi,

    library naming is something OS related (for instance the filename for a dynamic library called foo on Windows with Visual Studio will be foo.dll, on Linux, on OS X libfoo.dylib).

    For this reason when you pass the library name to the linker you have to omit the prefix (ususally lib) and the extension.

    NOTE in case of MinGW you'll have the naming conventions used in Linux/Unix (lib<library_name>.<extension>)

Log in to reply