How to create a simple project that would use compiled for VC staticaly linked boost (that is somewhhere like C:/boost)? How shall my project file look like?
I tried to add to .pro
INCLUDEPATH += C:/BOOST/include/boost-1_49
DEPENDPATH += C:/BOOST/lib
LIBS += -LC:/BOOST/lib -llibboost_system-vc100-mt-sgd-1_49 -llibboost_thread-vc100-mt-sgd-1_49
but I get:
msvcprtd.lib(MSVCP100D.dll):-1: ERROR: LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in libboost_system-vc100-mt-sgd-1_49.lib(error_code.obj)
msvcprtd.lib(MSVCP100D.dll):-1: ERROR: LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in libboost_system-vc100-mt-sgd-1_49.lib(error_code.obj)
msvcprtd.lib(MSVCP100D.dll):-1: ERROR: LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in libboost_system-vc100-mt-sgd-1_49.lib(error_code.obj)
:-1: WARNING: LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
debug\loader.exe:-1: ERROR: LNK1169: one or more multiply defined symbols found
when I try to compile something like:
#include <QtGui/QApplication>
#include <iostream>
#include <boost/filesystem.hpp>
int main(int argc, char *argv[])
{
boost::filesystem::path p;
}
So I wonder how shall I change my .proo file to link correctly to static boost compiled for VC using Qt Creator that is using VS compiler?
If you built boost with the
--runtime-link=staticflag then they were compiled against the static CRT libraries, i.e. using the/MT(and/MTdfor debug) compiler flags.Your errors suggest your project is trying to link with the dynamic CRT lib, i.e. using
/MDand/MDd. If these are set in your .pro file, they will be a part of theQMAKE_CXXFLAGS_RELEASEandQMAKE_CXXFLAGS_DEBUGvariables. They might however not be listed at all – I think the default is to use the dynamic CRT lib.All the libraries in your project need to link against the same CRT.
You either need to use
--runtime-link=sharedwhen building boost (you can still use--link=staticto create static boost libs with this option though), or add/change the/MDand/MDdto/MTand/MTdin your .pro file.