Scenario: I was attempting to get my C++ CMake Qt/Boost based project building on Windows.
I was getting linking errors such as:
LNK2019: unresolved external symbol "private: class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >
Solution: Ensure Boost has been built for the correct architecture! (x86 vs x64)
Steps taken:
- Installed Visual Studio Express 2013 Desktop (VS 2015 is still in RC)
- Installed the Windows 8.1 SDK
- Installed the Qt SDK including QtCreator
- installed CMake
- Installed Boost
- Extracted Boost download to C:\Program Files\boost_1_58_0
- Opened a VS2013 x64 Cross Tools command prompt
- Run bootstrap.bat in the boost directory
- Built 64 bit Boost libraries. This was the crucial part I had missed before, and by default b2 was generating x86 libraries. The address-model parameter is the key part
C:\Program Files\boost_1_58_0>b2 --toolset=msvc-12.0 architecture=x86 address-model=64 --with-regex --with-system --with-filesystem --build-type=complete stage
- Verify the libraries generated are 64 bit using the dumpbin tool. Look to see the “Machine” line says (x64).The libraries will have been output into stage\lib in the previous step
C:\Program Files\boost_1_58_0\stage\lib\>dumpbin /headers *.lib
Version : 0
Machine : 8664 (x64)
TimeDateStamp: 55463452 Sun May 03 15:44:34 2015
SizeOfData : 00000058
DLL name : boost_filesystem-vc120-mt-1_58.dll
Symbol name : ?absolute@filesystem@boost@@YA?AVpath@12@AEBV312@0@Z (class boo
st::filesystem::path __cdecl boost::filesystem::absolute(class boost::filesystem
::path const &,class boost::filesystem::path const &))
Type : code
Name type : name
Hint : 46
Name : ?absolute@filesystem@boost@@YA?AVpath@12@AEBV312@0@Z
- Success!