简体   繁体   English

如何指定要链接到哪个版本的Boost库?

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

I'm trying to migrate a project written in VS2012 to VS2013. 我正在尝试将用VS2012编写的项目迁移到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 . 我成功地编译了boost 1.53.0(我第一次尝试了1.54.0,但是遇到了一些编译器错误),并且得到了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? 我该如何解决我的问题?

I found the answer to my question and the solution to my problem in TheArtTrooper's answer to this thread: 我在TheArtTrooper对此线程的答案中找到了问题的答案和问题的解决方案:

How do I build boost with new Visual Studio 2013 preview? 如何使用新的Visual Studio 2013预览版构建增强功能?

The linker does know which library to use, because it is specified in boost/config/auto_link.hpp . 链接器知道要使用哪个库,因为它是在boost / config / auto_link.hpp中指定的。

This file is missing a few lines of code to handle the vc120 version: 此文件缺少处理vc120版本的几行代码:

#  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! 现在它可以编译和链接了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM