Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify, which version of boost library to link to?

I'm trying to migrate a project written in VS2012 to VS2013.

I successfully compiled boost 1.53.0 (I first tried 1.54.0, but got some compiler errors) and got libraries like libboost_filesystem-vc120-mt-1_53.lib.

But when trying to build my project, the linker complains:

error LNK1104: cannot open file 'libboost_filesystem-vc110-mt-1_53.lib'

I've been looking for some project settings in my entire solution to find out, why it's trying to load the older library version, but I didn't find anything.

How does the linker know, which library to use? And how can I fix my problem?

like image 714
Ben Avatar asked Nov 06 '13 16:11

Ben


People also ask

How do I check my Boost library version?

You can check version. hpp inside Boost include dir (normally /usr/include/boost , you can use locate /boost/version. hpp or similar to get that) for BOOST_VERSION or BOOST_LIB_VERSION .

Is Boost library backwards compatible?

Many of the Boost libraries are actively maintained and improved, so backward compatibility with prior version isn't always possible. Deal with this by freezing the version of the Boost libraries used by your project. Only upgrade at points in your project's life cycle where a bit of change will not cause problems.

How do I link my Boost library to Windows?

6.1 Link From Within the Visual Studio IDEIn Configuration Properties > Linker > Additional Library Directories, enter the path to the Boost binaries, e.g. C:\Program Files\boost\boost_1_55_0\lib\. From the Build menu, select Build Solution.

What is Boost version?

Boost is a set of libraries for the C++ programming language that provides support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, and unit testing. It contains 164 individual libraries (as of version 1.76).


1 Answers

I found the answer to my question and the solution to my problem in TheArtTrooper's answer to this thread:

How do I build boost with new Visual Studio 2013 preview?

The linker does know which library to use, because it is specified in boost/config/auto_link.hpp.

This file is missing a few lines of code to handle the vc120 version:

#  elif defined(BOOST_MSVC) && (BOOST_MSVC < 1800)

     // vc11:
#    define BOOST_LIB_TOOLSET "vc110"

#  elif defined(BOOST_MSVC)

     // vc12:
#    define BOOST_LIB_TOOLSET "vc120"

Now it compiles and links just fine!

like image 154
Ben Avatar answered Oct 24 '22 14:10

Ben