6
votes

I'm trying to link to several boost libraries (the ones that need to be compiled) in visual studio 2013 and am having trouble doing so.

I've installed the boost files by runing from the command line

boostrap.bat

and

b2 --toolset=msvc-12.0 --build-type=complete architecture=x86 address-model=64 stage

so that the libraries are in C:\boost_1_56_0/stage/lib

In my project I go into configuration properties>c/c++>General>Additional include directories and include C:\boost_1_56_0 and include headers using for example #include<boost/serialization/vector.hpp> among others

I then go to configuration properties>linker>additional library dependencies and include C:\boost_1_56_0\stage\lib

I am now aware that boost uses auto linking so I ensure that there are no attempts to directing link to the boost libraries in configuration properties>linker>input>additional dependencies

However I still get (many) linker errors of the following type:

error LNK2001: unresolved external symbol "public: void __thiscall boost::archive::detail::basic_oarchive::end_preamble(void)" (?end_preamble@basic_oarchive@detail@archive@boost@@QAEXXZ)

All the relevant questions I find concern misunderstandings of boost's auto linking facility, but I am now doing explicitly what I should be doing (to the best of my understanding). It is finding the the header files ok and the library files are where I am instructor the linker to look for them.

What might I be doing wrong?

2
Did you try the preprocess to a file option and examining the .i file to see what gets generated ?BlueTrin

2 Answers

0
votes

There are tons of articles for linking boost in visual studio in stack overflow. One of them which I find minimal/complete is How to use Boost in Visual Studio 2010

0
votes

I just run into similar question and share my idea with you. You are probably compiling both 32bit and 64bit libs for boost. Thus I guess you maybe have two directories which contains the libs with the same names but built in different platform,like $(BOOST154_NEW_HOME)\lib_x64 and $(BOOST154_NEW_HOME)\lib_x86. You should have included both paths in your configuration properties>linker>additional library dependencies. Though boost are using auto_link to find out which lib you want to use, but it still confused about which lib under 32 bit or 64 bit need to be imported.

My suggestion is that you should include only 64bit boost libs directory in your configuration properties>linker>additional library dependencies.