未定义的符号boost :: system:detail :: system_category_instance

时间:2018-12-11 15:15:15

标签: c++ boost-asio boost-filesystem boost-beast boost-system

在编译使用 beast asio 的运动场程序时,我已经在macOS Mojave上使用clang用c ++ 17标准构建了boost函数,但出现以下错误:< br /> enter image description here

这是我的制作文件:

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

C语版本:
Apple LLVM版本10.0.0.0(clang-1000.11.45.5)
目标:x86_64-apple-darwin18.2.0

还有什么我需要考虑的吗?我读过很多文章,等等,建议在项目本身应该使用的同一c ++标准中编译boost。

编辑:
Matthieu Brucher的变量名提示(Boost_ vs. BOOST_)成功了。现在可以了。

1 个答案:

答案 0 :(得分:0)

@Matthieu Brucher的提示(使用变量名(Boost_ vs. BOOST_))达到了目的:

target_link_libraries(Playground ${Boost_FILESYSTEM_LIBRARY}
                                  ${Boost_SYSTEM_LIBRARY})