【问题标题】:CMake doesn't find boostCMake 找不到提升
【发布时间】:2012-10-24 19:01:54
【问题描述】:

Windows 7. 64 位。 CMake 2.8.10。

步骤:

cd C:\work\lib\boost_1_51_0-MT 引导程序.bat bjam --toolset=msvc-10.0 --variant=release --build-type=complete -j 4 --with-regex --with-test --with-filesystem --with-date_time --with-random -- with-system --with-thread --with-program_options --with-chrono --with-math stage link=static threading=multi runtime-link=static
  • 命令:
设置 BOOST_ROOT=C:\work\lib\boost_1_51_0-MT cmake M:\项目 找不到请求的 Boost 库。 增强版:1.51.0 Boost 包含路径:C:/work/lib/boost_1_51_0-MT 找不到以下 Boost 库: 升压系统 boost_thread boost_random boost_chrono 没有找到 Boost 库。您可能需要将 BOOST_LIBRARYDIR 设置为 包含 Boost 库或 BOOST_ROOT 的目录到 促进。

M:\project\CMakeLists.txt 包含:(我需要静态链接 boost)

... set_property(全局属性 FIND_LIBRARY_USE_LIB64_PATHS ON) 设置(USE_STATIC_BOOST ON) 添加定义(-DBOOST_THREAD_USE_LIB) 添加定义(-DBOOST_ALL_NO_LIB) find_package(Boost 1.48.0 COMPONENTS 系统线程随机计时需要) ...

这个 CMakeLists.txt 是旧的,适用于其他 boost 安装(由我完成,而不是我过去,但收据丢失了)。

已解决

设置(Boost_USE_STATIC_LIBS ON)

...现在 CMake 找到了 boost 库!虽然我的"set(USE_STATIC_BOOST ON)" 肯定是一样的效果,但是没有……

【问题讨论】:

  • 将“已解决”部分作为答案发布并接受它可能是有意义的。

标签: c++ boost cross-platform cmake


【解决方案1】:

已解决

设置(Boost_USE_STATIC_LIBS ON)

...现在 CMake 找到了 boost 库!虽然我的 CMakeLists.txt 有 set(USE_STATIC_BOOST ON) 必须有相同的效果,但它没有......

要使用set(Boost_USE_STATIC_LIBS OFF),您需要添加:

if( WIN32 )
  # Needed for boost to turn off autolinking for dynamic linking
  add_definitions( -DBOOST_ALL_NO_LIB )
endif()

查看更多信息: Linking boost library with Boost_USE_STATIC_LIB OFF on Windows

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-18
    • 1970-01-01
    • 2016-04-18
    • 1970-01-01
    • 2021-02-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多