VS2013始终链接到1.55.0 boost库

时间:2014-09-30 15:26:39

标签: boost visual-studio-2013 cmake

我正在将我的代码迁移到Visual Studio 2013,Professional(从2005年开始)。为此,我安装了cmake 3.0.2(以前的版本2.8)并编译了boost 1.56.0(之前的版本1.47.0)。

找到提升的CmakeList.txt是:

# find the boost installed path from environment variable
set(BOOST_ROOT_DIR "$ENV{BOOST_ROOT_DIR}")
if(BOOST_ROOT_DIR)
  message( "Boost found at ${BOOST_ROOT_DIR}")
else(BOOST_ROOT_DIR)
  set(BOOST_ROOT_DIR "$ENV{BOOST_ROOT}")
  if(BOOST_ROOT_DIR)
  else(BOOST_ROOT_DIR)
    message( FATAL_ERROR "BOOST is not installed")
  endif()
endif(BOOST_ROOT_DIR)
include_directories("${BOOST_ROOT_DIR}")

此处,环境变量BOOST_ROOT_DIR设置为安装我的boost的路径。

现在,当我构建我的项目时,它正在给我链接错误,如:

LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc120-mt-s-1_55.lib'

我看到的问题是,我编译了boost 1.56.0但是它试图链接1.55.0版本库。

我无法理解为什么会这样。

请帮忙。

编辑:我使用命令编译了我的提升:

bjam --toolset=msvc-12.0 variant=debug,release link=static runtime-link=static address-model=64

1 个答案:

答案 0 :(得分:0)

这意味着您的代码需要包含在thread中的Boost CMakeLists.txt组件(其他类似组件),如:

set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED thread) # name the needed components explicitly
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIR})
target_link_libraries(yourProject ${Boost_LIBRARIES})