【问题标题】:Getting CMake on Windows to find the vc120 Boost libraries在 Windows 上获取 CMake 以查找 vc120 Boost 库
【发布时间】:2015-05-31 09:39:04
【问题描述】:

CMake 正在寻找与我安装的不同的 boost 文件,但我不知道如何修复它。我在 64 位 Windows 7、VisualStudio Community 2015 上,并使用最新的 64 位版本的 Boost boost_1_58_0-msvc-12.0-64.exe

我的 CMake 文件的相关部分是这样的:

SET          ( Boost_DEBUG                ON  )
SET          ( Boost_DETAILED_FAILURE_MSG ON  )
SET          ( Boost_USE_STATIC_LIBS      ON  )
SET          ( Boost_USE_MULTITHREADED    ON  )
SET          ( Boost_USE_STATIC_RUNTIME   OFF )
FIND_PACKAGE ( Boost COMPONENTS regex date_time REQUIRED )

启用调试和详细消息后,我可以看到 CMake 正在寻找正确的位置,但正在寻找“vc140”而不是“vc120”:

location of version.hpp: C:/boost_1_58_0/boost/version.hpp
version.hpp reveals boost 1.58.0
guessed _boost_COMPILER = -vc140
_boost_MULTITHREADED = -mt
_boost_RELEASE_ABI_TAG = -
_boost_DEBUG_ABI_TAG = -gd
_boost_LIBRARY_SEARCH_DIRS = C:\boost_1_58_0\lib64-msvc-12.0;C:\boost_1_58_0/lib;C:\boost_1_58_0/stage/lib;C:/boost_1_58_0/lib;C:/boost_1_58_0/../lib;C:/boost_1_58_0/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
Searching for REGEX_LIBRARY_RELEASE:
libboost_regex-vc140-mt-1_58;
libboost_regex-vc140-mt;
libboost_regex-mt-1_58;
libboost_regex-mt;
libboost_regex

我拥有的文件以“120”命名:

>dir /b c:\boost_1_58_0\lib64-msvc-12.0\libboost_regex-*
libboost_regex-vc120-mt-1_58.lib
libboost_regex-vc120-mt-gd-1_58.lib
libboost_regex-vc120-mt-s-1_58.lib
libboost_regex-vc120-mt-sgd-1_58.lib
libboost_regex-vc120-s-1_58.lib
libboost_regex-vc120-sgd-1_58.lib

我假设“120”是指 VisualStudio 的版本?如何让 CMake 找到 vc120 文件?

【问题讨论】:

    标签: boost cmake visual-studio-2015


    【解决方案1】:

    名为Boost_COMPILER 的鲜为人知的变量就是解决方案。所以就我而言,要强制 CMake 寻找 vc120 而不是默认的 vc140,我必须像这样运行 cmake:

    >cmake -DCMAKE_BUILD_TYPE=Release -DBoost_COMPILER=-vc120 -DBOOST_ROOT=C:\boost_1_58_0 -DBOOST_LIBRARYDIR=C:\boost_1_58_0\lib64-msvc-12.0 -G "Visual Studio 14" ..
    

    【讨论】:

    • 我不确定这项工作的效果如何——您将使用 VC14 构建自己的代码,但会与使用 VC12 构建的 Boost 库链接。仅下载 Boost 源并使用 VC14 构建所需的库可能更安全?
    • 最后,我放弃了,回到了早期版本的 Visual Studio。在预发布的 VS 2015 中编译一些模板代码时遇到问题。所以我不知道@Fraser 是否正确,这最终会导致问题。
    猜你喜欢
    • 2012-12-29
    • 1970-01-01
    • 2020-11-29
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    • 2019-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多