找不到带有 cmake 的提升库
Cannot find boost libraries with cmake
我已经在Windows上安装了boost 1.63.0,我正在尝试使用CMake进行构建(使用Visual Studio 2017作为生成器)。我无法find_package()
找到我的提升库,我不知道为什么。
CMakeLists.txt:
find_package(Boost REQUIRED COMPONENTS system filesystem thread)
输出:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.8/Modules/FindBoost.cm
ake:1813 (message):
Unable to find the requested Boost libraries.
Boost version: 1.63.0
Boost include path: C:/Program Files (x86)/boost/boost_1_63_0
Could not find the following Boost libraries:
boost_system
boost_filesystem
boost_thread
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Boost 会查找包含内容,但不查找库。 标头位于:%BOOST_ROOT%
. 图书馆位于%BOOST_ROOT%/stage/lib
。 当我看_boost_LIBRARY_SEARCH_DIRS_RELEASE
时,它首先看到的地方是正确的位置。 为了确定,我还尝试将BOOST_LIBRARYDIR
硬编码到该路径。
为了安装 boost,我将下载的存档提取到%BOOST_ROOT%
,然后运行bootstrap
并.b2 link=static,shared threading=single,multi
。 这应该为我提供库的所有版本。 在 boost:system 的情况下,我%BOOST_ROOT%/stage/lib%
有以下二进制文件:
boost_system-vc100-mt-1_63.dll
boost_system-vc100-mt-1_63.lib
boost_system-vc100-mt-gd-1_63.dll
boost_system-vc100-mt-gd-1_63.lib
libboost_system-vc100-mt-1_63.lib
libboost_system-vc100-mt-gd-1_63.lib
我尝试启用和禁用以下内容,但无济于事:
set( Boost_USE_STATIC_LIBS ON )
set( Boost_USE_MULTITHREADED OFF )
set( Boost_DEBUG ON )
这是一个有趣的部分。Boost_DEBUG
参数吐出这一行:
Searching for SYSTEM_LIBRARY_RELEASE: boost_system-vc141-mt-1_63;boost_system-vc141-mt;boost_system-mt-1_63;boost_system-mt;boost_system
请注意 vc141 与 vc100。 我认为.\b2为vc100构建了一些东西。 这很奇怪,因为我是从VS 2017的开发命令提示符运行它的。 我做了一个疯狂的猜测,并试图用./b2 toolset=msvc-14.1
建立提升,但我得到一个错误:*** argument error * rule maybe-rewrite-setup ( toolset : setup-script : setup-options : version : rewrite-setup ? )".
如何确保使用 VS2017 或 MSVC141 编译 boost?
这个线程似乎相关: Visual Studio 2017、Boost 和 CMake 的版本号
检查正在使用的FindBoost.cmake
脚本。根据您使用的 CMake 版本,可能无法处理此版本的 Boost。库之间的依赖关系根据找到的 Boost 版本进行设置。
例如,GitHub 上的 CMake 源中最新版本的脚本处理版本 1.63。我在 CMake v3.6.2 中遇到了问题,它无法处理它。
关于MSVC的版本不匹配我不知道,抱歉。
我编译了 boost,并使用相同的工具集编译链接应用程序。因此,我决定将所有编译的库从 *-vc100-* 重命名为 *-vc141-*是安全的。 虽然通常我会不鼓励这样做(你可能会在 ABI 中获得细微的差异),但在这种情况下,我确信它是相同的编译器,所以很明显 cmake 或 b2 有一个错误,它创建(或搜索)一个文件名错误的文件。
这样做之后,cmake不仅找到了提升,而且成功链接。
- 将库链接到另一个应用程序时,CMAKE 找不到库
- CMake 找不到变量或目录
- Cmake 找不到创建的库 (libgps)
- CMake 找不到请求的 Boost 库
- CMake 找不到带有 brew boost_python lib (macOS)
- Cmake找不到"openssl" "libcrypto" pkg_search_module
- 为什么Cmake找不到编译器CL
- CMake 找不到旧版库
- C++ CMake 找不到 Boost 1.63(使用 CLion IDE)
- 为什么 CMAKE 找不到这些变量?
- CMake 找不到源文件,即使它位于正确的位置
- cmake 找不到随 vcpkg 一起安装的库
- CMake 找不到与 "Unix Makefiles" 对应的构建程序
- cmake找不到Gurobi外部库
- Cmake找不到boost库文件,线程,date_time,iostreams,system
- CMake 找不到提升。
- Cmake找不到提升
- Cmake找不到OpenCV库
- Cmake 找不到提升文件夹
- CMake 找不到特定的提升库 (boost_random)