1
votes

I'm using Boost 1.54 and Qt 5.3.2 in Visual Studio 2010. I'm trying to use the static libs of Boost Filesystem. However, whenever I try to build my application, I get the following linking errors:

libboost_filesystem-mt.lib(path.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::codecvt<wchar_t,char,int>::codecvt<wchar_t,char,int>(unsigned int)" (__imp_??0?$codecvt@_WDH@std@@QAE@I@Z)
libboost_filesystem-mt.lib(path.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) private: __thiscall std::locale::_Locimp::_Locimp(class std::locale::_Locimp const &)" (__imp_??0_Locimp@locale@std@@AAE@ABV012@@Z)
libboost_filesystem-mt.lib(path_traits.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::codecvt<wchar_t,char,int>::in(int &,char const *,char const *,char const * &,wchar_t *,wchar_t *,wchar_t * &)const " (__imp_?in@?$codecvt@_WDH@std@@QBEHAAHPBD1AAPBDPA_W3AAPA_W@Z)
libboost_filesystem-mt.lib(path_traits.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::codecvt<wchar_t,char,int>::out(int &,wchar_t const *,wchar_t const *,wchar_t const * &,char *,char *,char * &)const " (__imp_?out@?$codecvt@_WDH@std@@QBEHAAHPB_W1AAPB_WPAD3AAPAD@Z)

Here are some additional information about my project settings, which may be of help:

  • BOOST_ALL_NO_LIB in Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions
  • Multi-threaded (/MT) in Configuration Properties > C/C++ > Code Generation > Runtime Library
  • libboost_filesystem-mt.lib and libboost_system-mt.lib in Configuration Properties > Linker > Input > Additional Dependencies
  • ..\Libraries\1.54.0\lib_win32 (Boost library folder) in Configuration Properties > Linker > General > Additional Library Directories
  • msvcrt.lib and msvcprt.lib in Configuration Properties > Linker > Input > Ignore Specific Default Libraries

What could be the problem? I have read on the Internet that Boost does not work very well with Qt. Could that be the problem?

1
msvcrt.lib and msvcprt.lib in Configuration Properties > Linker > Input > Ignore Specific Default Libraries A lot of times this is a sign of a problem. Make sure Qt and boost were both built with the Visual Studio 2010 and you used the same CRT. - drescherjm
Is there a way to look if Qt and Boost have the same CRT once they are built? - Javiator
Use dependency walker. if they depend on msvcrt.dll it is the static crt, otherwise it is a dynamic crt. For vs2010 it is named msvcr100.dll. - UmNyobe
What do I have to open in Dependency Walker? Because the *.lib files cannot be opened. - Javiator

1 Answers

2
votes

As drescherjm pointed out you have an different runtime libraries :

  • Unless you built it yourself Qt use the dynamic version of the CRT
  • libboost_filesystem-mt.lib is the static build linking to the static version of the CRT
  • The /MT option specify that this project should use the static version of the CRT when built

Alternative 1 : Use the Multithreaded, dynamic link version of the CRT for all

  • Remove msvcrt.lib and msvcprt.lib libs from Ignore Specific Default Libraries
  • Use boost_filesystem-vc100-mt-1_54.dll and boost_system-vc100-mt-1_54.lib
  • Use /MD instead of /MT

Alternative 2 : Built Qt yourself with /MT instead of /MD

Note: