我不能建立一个简单的Hello程序在GCC-6,但它的工作与Clang在克里昂。

现在我尝试在这里构建并运行第一个Boost日期时间示例。
我的CMake看起来就像
cmake_minimum_required(VERSION 3.16)
project(Boost_Run_2)
set(CMAKE_CXX_STANDARD 11)
find_package(Boost REQUIRED COMPONENTS date_time)
add_executable(Boost_Run_2 main.cpp)
target_link_libraries(Boost_Run_2 PRIVATE Boost::date_time)但是它将链接器错误抛出为
====================[ Build | Boost_Run_2 | Debug ]=============================
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/alihasan/Documents/GSOC/Boost_Run_2/cmake-build-debug --target Boost_Run_2 -- -j 4
Scanning dependencies of target Boost_Run_2
[ 50%] Building CXX object CMakeFiles/Boost_Run_2.dir/main.cpp.o
[100%] Linking CXX executable Boost_Run_2
Undefined symbols for architecture x86_64:
"boost::gregorian::greg_month::get_month_map_ptr[abi:cxx11]()", referenced from:
unsigned short boost::date_time::month_str_to_ushort<boost::gregorian::greg_month>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in main.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[3]: *** [Boost_Run_2] Error 1
make[2]: *** [CMakeFiles/Boost_Run_2.dir/all] Error 2
make[1]: *** [CMakeFiles/Boost_Run_2.dir/rule] Error 2
make: *** [Boost_Run_2] Error 2当我使用Clang运行相同的程序时,我能够运行它。没有链接错误。所以我假设我的助推图书馆已经被正确地设置好了。
我希望能够使用GCC-6/G++-6运行同一个程序.
我有一个macOS Mojave 10.14.3,我使用brew install boost安装Boost库。
发布于 2020-06-03 00:52:48
我解决了这个问题。
我意识到我的Boost库安装不正确。
出于某种原因,Homebrew没有正确安装Boost库,您必须按照文档中提到的方式安装它。
https://stackoverflow.com/questions/62162708
复制相似问题