1

在编译使用beastasio的游乐场程序时,我在 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: 使用 Clang 编译 Boost

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_)起到了作用。现在它正在工作。

4

1 回答 1

0

@Matthieu Brucher 的变量名提示(Boost_ vs. BOOST_)起到了作用:

target_link_libraries(Playground ${Boost_FILESYSTEM_LIBRARY}
                                  ${Boost_SYSTEM_LIBRARY})
于 2018-12-11T21:00:58.353 回答