【问题标题】:CMake errors when building cpprestsdk构建 cpprestsdk 时出现 CMake 错误
【发布时间】:2017-09-16 23:16:05
【问题描述】:

我正在尝试在 MSYS2 下构建 cpprestsdk (https://github.com/Microsoft/cpprestsdk)。使用 pacman 我安装了所需的依赖项:

  • 提升
  • openssl

但我得到以下输出:

$ cmake -G "MSYS Makefiles" .. -DCMAKE_BUILD_TYPE=Release
-- Setting gcc options
-- Added test library httpclient_test
-- Added test library httplistener_test
-- Added test library json_test
-- Added test library pplx_test
-- Added test library streams_test
-- Added test library uri_test
-- Added test library utils_test
-- Added test library websocketclient_test CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the
CMake files:
C:/cpprestsdk/Release/src/Boost_INCLUDE_DIR
used as include directory in directory
C:/cpprestsdk/Release/src
C:/cpprestsdk/Release/tests/functional/streams/Boost_INCLUDE_DIR
used as include directory in directory
C:/cpprestsdk/Release/tests/functional/streams
C:/cpprestsdk/Release/tests/functional/websockets/Boost_INCLUDE_DIR
used as include directory in directory
C:/cpprestsdk/Release/tests/functional/websockets

-- Configuring incomplete, errors occurred! See also "C:/cpprestsdk/Release/build.release/CMakeFiles/CMakeOutput.log".

我很难理解这些错误的真正含义。 我试图检查日志输出,但没有发现任何明显的...

我是否缺少其他一些依赖项?

更新

在@Some程序员老兄的好建议下,我修复了cmakeCMakelist.txt中设置Boost_INCLUDE_DIR的错误。

但是当我发出make 命令时,我现在有了这个:

$ make
Scanning dependencies of target cpprest
[  0%] Building CXX object src/CMakeFiles/cpprest.dir/http/client/http_client.cpp.obj
cc1plus.exe: error: /mingw32/include/boost: No such file or directory [-Werror=missing-include-dirs]

它说找不到/mingw32/include/boost,但它确实存在:

$ ls /mingw32/include/boost/
accumulators             context                       fusion                  make_unique.hpp                predef                         spirit
algorithm                convert                       generator_iterator.hpp  math                           predef.h                       spirit.hpp
align                    convert.hpp                   geometry                math_fwd.hpp                   preprocessor                   statechart
align.hpp                core                          geometry.hpp            mem_fn.hpp                     preprocessor.hpp               static_assert.hpp
aligned_storage.hpp      coroutine                     get_pointer.hpp         memory_order.hpp               program_options                swap.hpp
any.hpp                  coroutine2                    gil                     metaparse                      program_options.hpp            system
...

我没有提出另一个问题,因为我担心这个问题与前一个问题有关 - 没有完全解决。

【问题讨论】:

  • 可能存在 CMakeLists.txt 文件不检查 Boost 或其位置的错误?如果手动将Boost_INCLUDE_DIR 设置为Boost 头文件的位置会发生什么?您是否尝试过向项目维护者报告(通过添加issue on github)?
  • 如何设置变量?我尝试导出它:export Boost_INCLUDE_DIR=/mingw32/include/boost/ 但没有任何改变
  • 设置CMAKE_BUILD_TYPE的方式相同。请花点时间阅读the CMake documentation(例如如何使用the cmake command)。
  • 解决了在 CMakeLists.txt 中添加set(Boost_INCLUDE_DIR "/mingw32/include/boost/")。如果您将评论更改为答案,我会接受。谢谢

标签: c++ boost cpprest-sdk


【解决方案1】:

如果您要修改 OpenSSL 或 Boost 位置,则应修改文件:

cpprest_find_boost.cmake cpprest_find_openssl.cmake

您可以看到针对不同平台的不同管理方式。我已经针对 iOS 进行了修改,以使用静态库而不是他们使用的框架解决方案。

两者都需要为每个相应的库提供正确的包含和正确的库路径。

【讨论】:

    猜你喜欢
    • 2013-05-25
    • 1970-01-01
    • 1970-01-01
    • 2019-02-03
    • 2017-04-08
    • 2018-07-24
    • 1970-01-01
    • 2016-06-17
    • 2019-10-15
    相关资源
    最近更新 更多