使用CMake构建cpp-netlib

时间:2016-05-01 20:16:04

标签: c++ cpp-netlib

我已经下载了cpp-netlib源代码,将其解压缩到一个文件夹中,由于某种原因,我完全迷失了。我仔细阅读了文档,它说我必须下载CMake,我做了。然后我设置源目录和构建目录,单击“生成”按钮后,我得到了这个输出:

The CXX compiler identification is MSVC 19.0.23506.0
Check for working C compiler using: Visual Studio 14 2015
Check for working C compiler using: Visual Studio 14 2015 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 14 2015
Check for working CXX compiler using: Visual Studio 14 2015 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindBoost.cmake:1657 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.
Call Stack (most recent call first):
  CMakeLists.txt:49 (find_package)


Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing:  OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) 
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE  
CMake Error at CMakeLists.txt:131 (export):
  export given target "cppnetlib-client-connections" which is not built by
  this project.


Configuring incomplete, errors occurred!
See also "C:/Users/Nick/Documents/cpp-netlib/cpp-netlib-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Nick/Documents/cpp-netlib/cpp-netlib-build/CMakeFiles/CMakeError.log"

它无法找到Boost库,而这就是我被困住的地方。我安装了boost,但我不知道在哪里设置“BOOST_ROOT”。我做了一些研究,尝试使用-DBOOST_ROOT选项的命令行,如下所示:

c:\Program Files>cmake -DBOOST_ROOT=/boost/boost_1_55_0

但它给了我以下错误:

CMake Error: The source directory "C:/Program Files" does not appear to contain
CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

我真的不确定现在要做什么,我觉得这不是我问题的结束......有什么明显的我遗失了吗?

1 个答案:

答案 0 :(得分:1)

您需要从源树(包含CMakeLists.txt)运行cmake,或者更典型地,从构建文件夹运行它并告诉它源树的位置。 一个常见的情况是在源树旁边创建一个构建文件夹并运行cmake ../sourcedir

你似乎最初使用的是gui;当然,这提供了一种设置BOOST_ROOT变量的方法吗?

或者,如果您只是将VC放入VC ++ include / lib路径(在vc目录中,或通过设置%INCLUDE%/%LIB%),您可能不需要BOOST_ROOT。与OpenSSL相同。