我使用自制软件在MacOS High Sierra 10.13.3上安装了Boost 1.60:brew install boost@1.60
我使用我的工具链设置运行 CLion 2018.1.1 ,如下所示:捆绑 CMake 3.10.3 ,C ++编译器/Library/Developer/CommandLineTools/usr/bin/c++
,GNU 制作3.81
我的 CMakeLists.txt 文件如下:
cmake_minimum_required(VERSION 3.10)
project(xxx)
set(CMAKE_CXX_STANDARD 17)
add_executable(${PROJECT_NAME} main.cpp)
Set(BOOST_ROOT /usr/local/Cellar/boost@1.60/1.60.0)
find_package(Boost 1.60.0 REQUIRED COMPONENTS system filesystem regex)
if(Boost_FOUND)
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "Boost_VERSION: ${Boost_VERSION}")
include_directories(${BOOST_ROOT})
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
endif()
构建似乎成功:
-- Boost version: 1.60.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- regex
-- Boost_INCLUDE_DIRS: /usr/local/Cellar/boost@1.60/1.60.0/include
-- Boost_LIBRARIES: /usr/local/Cellar/boost@1.60/1.60.0/lib/libboost_system-mt.dylib;/usr/local/Cellar/boost@1.60/1.60.0/lib/libboost_filesystem-mt.dylib;/usr/local/Cellar/boost@1.60/1.60.0/lib/libboost_regex-mt.dylib
-- Boost_VERSION: 106000
但是当我尝试执行时,我收到以下链接器错误:
架构x86_64的未定义符号: “boost :: re_detail_106000 :: perl_matcher,std :: __ 1 :: allocator>&gt ;, boost :: regex_traits>> :: construct_init(boost :: basic_regex>> const&,boost :: regex_constants :: _match_flags)“,引自: boost :: re_detail_106000 :: perl_matcher,std :: __ 1 :: allocator> >,boost :: regex_traits> > :: perl_matcher(std :: __ 1 :: __ wrap_iter,std :: __ 1 :: __ wrap_iter,boost :: match_results,std :: __ 1 :: allocator>>>&,boost :: basic_regex>> main.cpp.o中的; const&,boost :: regex_constants :: _ match_flags,std :: __ 1 :: __ wrap_iter) “boost :: re_detail_106000 :: perl_matcher,std :: __ 1 :: allocator>&gt ;, boost :: regex_traits>> :: match()”,引自: bool boost :: regex_match,std :: __ 1 :: allocator> >,char,boost :: regex_traits> >(std :: __ 1 :: __ wrap_iter,std :: __ 1 :: __ wrap_iter,boost :: match_results,std :: __ 1 :: allocator>>>&,boost :: basic_regex>> const& ,main.cpp.o中的boost :: regex_constants :: _ match_flags) ld:找不到架构x86_64的符号
我做错了什么,我该如何解决?
答案 0 :(得分:0)
我的不好:在我的交叉构建中,我强迫 libc ++ 而不是 stdlibc ++
if (APPLE)
# add_definitions(-D__GLIBCXX__)