What's wrong with my boost? (macOS)
Completed
Here is my CMakeList.txt:
cmake_minimum_required(VERSION 3.27)
project(maxSubArray)
set(CMAKE_CXX_STANDARD 17)
find_package(Boost)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(maxSubArray main.cpp)
target_link_libraries(maxSubArray ${Boost_LIBRARIES})
And here is the issue:
====================[ 构建 | maxSubArray | Debug ]================================
/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake --build /Users/zhangjiaxin/CLionProjects/maxSubArray/cmake-build-debug --target maxSubArray -j 6
[1/1] Linking CXX executable maxSubArray
FAILED: maxSubArray
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/maxSubArray.dir/main.cpp.o -o maxSubArray && :
Undefined symbols for architecture arm64:
"boost::timer::format(boost::timer::cpu_times const&, short)", referenced from:
boost::timer::cpu_timer::format(short) const in main.cpp.o
"boost::timer::cpu_timer::start()", referenced from:
boost::timer::cpu_timer::cpu_timer() in main.cpp.o
"boost::timer::cpu_timer::elapsed() const", referenced from:
boost::timer::cpu_timer::format(short) const in main.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
What should I do?
Please sign in to leave a comment.
OK, it is solved.
Just write this line
find_package(Boost COMPONENTS ALL)