VS2013始终链接到1.55.0 boost库

VS2013始终链接到1.55.0 boost库,boost,visual-studio-2013,cmake,Boost,Visual Studio 2013,Cmake,我正在将代码迁移到Visual Studio 2013 Professional(从2005年开始)。为此,我安装了cmake 3.0.2(以前的版本2.8)并编译了boost 1.56.0(以前的版本1.47.0) 查找boost的CmakeList.txt是: # find the boost installed path from environment variable set(BOOST_ROOT_DIR "$ENV{BOOST_ROOT_DIR}") if(BOOST_ROOT_DI

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

查找boost的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\u ROOT\u DIR被设置为安装我的BOOST的路径

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

LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc120-mt-s-1_55.lib'
我看到的问题是,我已经编译了Boost1.56.0,但它正试图链接到1.55.0版本库

我无法理解为什么会发生这种情况

请帮忙

编辑:我已经使用以下命令编译了boost:

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

这意味着您的代码需要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})

谢谢你的回复。我无法理解的是,直到现在我还不需要明确地命名组件(直到我使用1.47.0),但为什么现在我需要提到它?另外,按照您所说的,它将如何链接到1.56.0版本?我还需要提到版本吗?@Garfield不需要提及版本,只要您将Boost路径设置为
Boost\u ROOT
environment。还要注意,在VS上,Boost将尝试自动链接库,这很容易与CMake断开。因此,一定要将
BOOST\u ALL\u NO\u LIB
添加到预处理器定义中。