OS X,CMake,Boost:架构x86_64的未定义符号:“ boost :: system :: detail :: generic_category_instance”

时间:2019-02-10 06:40:06

标签: c++ boost cmake

我正在尝试使用给定的指令编译this Git repo。但是,在cmake --build .;行,我遇到了以下问题。

Undefined symbols for architecture x86_64:
  "boost::system::detail::generic_category_instance", referenced from:
      boost::system::generic_category() in quorum_intersection.cpp.o
ld: symbol(s) not found for architecture x86_64

我编辑了CMakeLists.txt文件,以合并在类似的StackOverflow线程上看到的一些先前的答案。下面是我现在正在使用的CMakeLists.txt文件。

cmake_minimum_required (VERSION 2.6)
project (stellar-quorums-verifier)
set(CMAKE_CXX_STANDARD 14)

set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.66.0 COMPONENTS graph log program_options REQUIRED system)

if(Boost_FOUND)
    add_definitions(-DBOOST_LOG_DYN_LINK)
    include_directories(${Boost_INCLUDE_DIRS})
    add_executable(quorum_intersection quorum_intersection.cpp)
    target_link_libraries(quorum_intersection ${Boost_LIBRARIES})
    TARGET_LINK_LIBRARIES(quorum_intersection ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
endif()

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set (CMAKE_CXX_COMPILER_WORKS TRUE)
set (CMAKE_C_COMPILER_WORKS TRUE)

我通过下载源代码并运行./b2 cxxstd=14./b2 install来安装Boost,如here所述。

让我感到困惑的是,cmake ../;的输出中包含

-- Found Threads: TRUE  
-- Boost version: 1.68.0
-- Found the following Boost libraries:
--   graph
--   log
--   program_options
--   system
--   date_time
--   log_setup
--   filesystem
--   thread
--   regex
--   chrono
--   atomic
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Uthsav/Desktop/quorum_intersection-master/build

所以似乎应该定义系统?所以我不确定为什么为什么说boost :: system是不确定的。我花了整整一整夜的时间来尝试运行此Git存储库中的代码-如果有人有任何建议,我将不胜感激。

1 个答案:

答案 0 :(得分:0)

我通过添加使构建工作

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3 -lboost_system -lboost_thread")

到CMakeLists.txxt文件。不知道为什么会这样,但是我在某处在线找到了它。