【问题标题】:How to find Boost filesystem library compiled with VS 2017 with CMake?如何使用 CMake 查找使用 VS 2017 编译的 Boost 文件系统库?
【发布时间】:2023-03-30 21:30:02
【问题描述】:

我已经使用 Visual Studio 2017 从源代码编译了 Boost,我正在使用 CMake 3.9.3 在我的 CMakeLists.txt 中通过以下命令找到它:

find_package(Boost REQUIRED COMPONENTS filesystem)

我正在像这样调用 CMake:

cmake -G "Visual Studio 15 2017" ..
    -DBOOST_ROOT="C:\Users\emlai\src\libs\boost_1_65_0"
    -DBOOST_LIBRARYDIR="C:\Users\emlai\src\libs\boost_1_65_0\lib64-msvc-15.0"

我收到以下消息:

CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1902 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.65.0

  Boost include path: C:/Users/emlai/src/libs/boost_1_65_0

  Could not find the following Boost libraries:

          boost_filesystem

  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.
Call Stack (most recent call first):
  CMakeLists.txt:31 (find_package)


CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  build/cmake-modules/FindSDL2.cmake:173 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:42 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/Users/emlai/src/zenith/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/emlai/src/zenith/build/CMakeFiles/CMakeError.log".

dir C:\Users\emlai\src\libs\boost_1_65_0\lib64-msvc-15.0 的输出表明文件系统库已就位。

我已经尝试了所有答案here,但没有成功。从 here 下载的预构建 Boost 库也是如此。

我该如何解决这个问题?

【问题讨论】:

  • 库是 x86 还是 x64?应用程序是在寻找 x86 还是 x64?
  • @BenVoigt x64,但没关系,让它工作。必须为 CMake 指定 Boost_COMPILER 变量。

标签: c++ visual-studio boost cmake visual-studio-2017


【解决方案1】:

我需要将 -DBoost_COMPILER="-vc141" 传递给 CMake 以使其工作(-vc141 与 Boost 库文件名中的字符串相同)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-24
    • 1970-01-01
    • 2012-04-10
    • 1970-01-01
    • 2017-04-12
    • 1970-01-01
    • 2011-10-26
    • 1970-01-01
    相关资源
    最近更新 更多