Using Boost With QtCreator?
-
I have been able to use <boost/filesystem> in Visual studio no problem but have had trouble getting it to work in QtCreator.
I first tried putting in my .Pro file
INCLUDEPATH += C:\boost\include\boost-1_59
LIBS += "-LC:\boost\boost_1_59_0\stage\lib"and get error
C:\boost\include\boost-1_59\boost\system\error_code.hpp:221: error: undefined reference to `boost::system::generic_category()'C:\boost\include\boost-1_59\boost\system\error_code.hpp:222: error: undefined reference to `boost::system::generic_category()'
C:\boost\include\boost-1_59\boost\system\error_code.hpp:223: error: undefined reference to `boost::system::system_category()'
collect2.exe:-1: error: error: ld returned 1 exit statusI looked around online and found some mention of problems like this but still couldn't get it to work.
I tried changing the .pro file to have
INCLUDEPATH += C:\boost\include\boost-1_59
LIBS += "-LC:\boost\boost_1_59_0\stage\lib" -llibboost_filesystem-vc140-mt-1_59And still get the same errors
Any help is appreciated
-
You should not use the "lib" prefix and the version string is probably not needed as well (but try with that string if it doesn't work without), so it should be:
LIBS += "-LC:\boost\boost_1_59_0\stage\lib" -lboost_filesystemOne more thing to consider: Boost libraries must be built using the same compiler you use to build your project!
-
@jsulm
So think I got it figured out. I went back and recompiled the libraries with MSVC 2010 which is what I am using with Qt.now my pro file looks like
INCLUDEPATH += C:\boost\boost_1_59_0\boost-dir\include LIBS += -L"C:\boost\boost_1_59_0\boost-dir\lib" -lboost_filesystem-vc100-mt-1_59
which builds fine. Posting this for future people stumbling down the same path.