【发布时间】:2018-12-11 15:15:15
【问题描述】:
在编译使用 beast 和 asio 的游乐场程序时,我在 macOS Mojave 上使用 c++17 标准和 clang 构建了 boost 我收到以下错误:
这是我的制作文件:
cmake_minimum_required (VERSION 3.13.1)
project (Playground)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USER_MULITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_ROOT "/usr/local/boost-1.68.0")
set(Boost_INLCUDE_DIR "/usr/local/boost-1.68.0/include")
set(Boost_LIBRARY_DIR_RELEASE "/usr/local/boost-1.68.0/lib")
find_package(Boost 1.68.0 REQUIRED COMPONENTS system filesystem)
set(SOURCES
src/main.cpp
src/http_client/http_client.hpp
src/http_client/http_client.cpp)
if(Boost_FOUND)
include_directories("/usr/local/boost-1.68.0/include")
add_executable (Playground ${SOURCES})
set_property(TARGET Playground PROPERTY CXX_STANDARD 17)
target_include_directories(Playground PRIVATE ${BOOST_INCLUDE_DIRS})
target_link_libraries(Playground ${BOOST_FILESYSTEM_LIBRARIES}
${BOOST_SYSTEM_LIBRARIES})
endif()
我使用本教程中描述的步骤编译了 boost: Compiling Boost with Clang.
Clang 版本:
Apple LLVM 版本 10.0.0.0 (clang-1000.11.45.5)
目标:x86_64-apple-darwin18.2.0
我还有什么需要考虑的吗?我已经阅读了很多帖子等,建议在项目本身应该使用的相同 c++ 标准中编译 boost。
编辑:
Matthieu Brucher 的变量名提示(Boost_ vs. BOOST_)起到了作用。现在它正在工作。
【问题讨论】:
-
特别是最后一个答案:您没有为 boost 安装/构建正确的架构,当您还需要 64 位时,只有 32 位。
-
另外真正的变量名是
Boost_SYSTEM_LIBRARY而不是BOOST_SYSTEM_LIBRARIES
标签: c++ boost-asio boost-filesystem boost-beast boost-system