【问题标题】:CMake is not finding Boost library binaries (new naming convention for the binaries)CMake 未找到 Boost 库二进制文件(二进制文件的新命名约定)
【发布时间】:2018-11-24 10:07:37
【问题描述】:

我首先说这不是环境变量的问题。

当我使用仅标头库时,一切正常:

set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED)

if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS})
    add_executable(TestCMake Program.cpp)
    target_link_libraries(TestCMake ${Boost_LIBRARIES})
endif()

但是当我尝试通过将 find_package(Boost REQUIRED) 更改为 find_package(Boost REQUIRED COMPONENTS system) 来要求一个库时,我收到一个错误:

Unable to find the requested Boost libraries.

Boost version: 1.67.0

Boost include path: D:/boost/boost_1_67_0

Could not find the following Boost libraries:

        boost_system

No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.

This answer 在另一个问题上表明 CMake 期望 Boost 二进制文件以某种方式命名:

boost_thread-vc100-mt-1_51
boost_thread-vc100-mt
boost_thread-mt-1_51
boost_thread-mt
boost_thread

我有一个名为boost_system-vc141-mt-x32-1_67.lib 的预编译二进制文件(从here 获得)。 如何让 CMake 识别我的二进制文件中使用的命名约定?

this downvoted answer 对其他问题的评论建议不要重命名文件。

【问题讨论】:

  • 您使用的是哪个 CMake 版本?只有在 3.11 之后,CMake 才支持新的 Boost 命名约定。您还可以在项目中使用更新的 FindBoost,它也可以。无需重命名。
  • 哇哦,我实际上使用的是 3.10。我现在已经为此浪费了 2 个多小时而感到非常愚蠢。

标签: c++ boost cmake


【解决方案1】:

在较新版本的 Boost(1.66 及更高版本)中,二进制文件的命名约定已更改。现在,又多了一个x64x32

因此,只有 1.66 Boost 版本之后的 CMake 版本具有此修复程序,从 3.11 开始就是这种情况。

所以有两个选择:

  • 将您的 CMake 版本升级到 3.11 以上版本
  • 使用这些较新 CMake 版本之一中的 FindBoost.cmake(它们通常是兼容的)。

如果您因公司政策而“卡住”一个版本,则必须使用后一种解决方案。

【讨论】:

  • 它在 3.12 中不起作用。 [ C:/Program Files/CMake/share/cmake-3.12/Modules/FindBoost.cmake:1809 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-mgw73-mt-d-1_68;libboost_system-mgw73-mt-d;libboost_system-mt-d-1_68;libboost_system-mt-d;libboost_system-mt;libboost_system;libboost_system-mgw73-mt-s-d-1_68;libboost_system-mgw73-mt-s-d;libboost_system-mt-s-d-1_68;libboost_system-mt-s-d
猜你喜欢
  • 2016-06-24
  • 1970-01-01
  • 2021-10-07
  • 2013-09-12
  • 1970-01-01
  • 2013-10-05
  • 2013-11-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多