【问题标题】:CMake with Boost library Windows 10 Library not found correctly未正确找到带有 Boost 库 Windows 10 库的 CMake
【发布时间】:2018-06-04 19:16:48
【问题描述】:

像许多其他人一样,我在使用带有 Windows 的 boost 库时遇到了问题。在 Ubuntu 16.04 上,它与 libboost-all-dev 配合得很好,但在 Windows 上我有很多问题。

我尝试构建一个cryptonote应用程序,我可以在linux下完全编译而没有任何错误。但我还需要 Windows 二进制文件,所以我执行了安装以下工具的步骤:

  • Visual Studio 2013 (vc120)
  • CMake 3.10.1
  • Python 3.6.4
  • 提升 1.58

为了提升,我做了以下步骤:

  • 从二进制安装 boost
  • 运行 bootstrap.bat
  • 运行 b2 安装
  • 运行 bjam install "--with-some-libs"

没有任何作用。 cryptonote 向我抛出了一个错误,即无法找到某些但不是所有库。

我尝试设置 BOOST_ROOT、BOOST_LIBRARY_DIRS、BOOST_INCLUDE_DIRS -> 什么都没有。

我做错了什么?我从 cmake 得到的错误是这样的:

-- Building for: Visual Studio 12 2013
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1928 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.58.0

  Boost include path: C:/local/boost_1_58_0

  Could not find the following static Boost libraries:

          boost_system
          boost_filesystem
          boost_thread
          boost_date_time
          boost_chrono
          boost_regex
          boost_serialization
          boost_program_options

  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:113 (find_package)


-- WARNING: Git was not found!
-- Found PythonInterp: C:/Users/chris/AppData/Local/Programs/Python/Python36-32/python.exe (found version "3.6.4")
CMake Warning in CMakeLists.txt:
  CMAKE_SKIP_INSTALL_RULES was enabled even though installation rules have
  been specified


-- Configuring incomplete, errors occurred!
See also "C:/Users/chris/Documents/GitHub/cryptonote/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/chris/Documents/GitHub/cryptonote/build/CMakeFiles/CMakeError.log".

也许有人可以帮助解决这个问题?

问候

【问题讨论】:

  • 使用 -DBoost_DEBUG=ON 重新运行 cmake 并分析其输出:无法找到哪些确切的文件以及在哪里搜索过它们。然后检查这些文件的 Boost 安装。
  • 好吧,你是对的。调试后,我注意到“libs”路径不在发布或调试的搜索路径中。但后来我尝试添加 -DBOOST_LIBRARY_DIR=PATHTOLIBS 无效。搜索路径不会改变。我也试过 -DBOOST_LIBRARY_DIRS=PATHTOLIBS.. 什么都没有。我通过谷歌等搜索了几个小时。我发现了很多命令,但没有什么真正有用的。谢谢你的帮助。第一步帮助我弄清楚问题出在哪里。但是我现在该如何解决这个问题。对不起我的菜鸟问题,但提升对我来说真的很新鲜。
  • 好吧,我找到了问题所在。例如 boost_serialization。它在正确的路径但使用文件名libboost_serialization-vc120-mt-s 搜索序列化。文件序列化存在,但文件名中没有s

标签: c++ boost cmake libraries


【解决方案1】:

好吧,在互联网上阅读了很多很多网页之后,我终于找到了解决方案。

解决方案非常简单。下载 boost 包并安装(或从源代码构建)后,您只需要以下两部分:

  • 打开你的 CMD (cmd.exe)
  • 切换到你的boost安装目录(例如C:\local\boost_1_58_0)

只需运行以下命令:

bootstrap.bat
b2 link=static runtime-link=static release stage

这将创建所有静态库并使其可用于 cmake。

这个解决方案对我有用,让我能够构建所需的包。

感谢所有帮助

【讨论】:

    【解决方案2】:

    或者你可以通过添加来告诉boost使用哪个编译器

    工具集=msvc-12.0

    (适用于 MS 2013 v12 等)

    到 b2 命令行 :-)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-29
      • 1970-01-01
      • 2014-01-06
      • 2016-04-21
      • 2012-12-29
      • 2011-12-26
      • 1970-01-01
      相关资源
      最近更新 更多