带有 Boost 库的 CMake Windows 10 找不到正确的库

CMake with Boost library Windows 10 Library not found correctly

像许多其他人一样,我在 windows 中使用 boost 库时遇到问题。在 Ubuntu 16.04 上,它与 libboost-all-dev 一起工作得很好,但在 windows 上我有很多问题。

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

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

没有任何效果。 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".

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

问候

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

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

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

只需运行以下命令:

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

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

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

感谢大家的帮助

或者您可以通过添加

来告诉 boost 使用哪个编译器

工具集=msvc-12.0

(适用于 MS 2013 v12 等)

到 b2 命令行:-)