我是c ++的新手,我在Mac上使用CLion。我想使用boost 1.65.0文件系统库。当我添加以下import语句时,控制台应用程序无法编译。
#include <boost/filesystem.hpp>
我收到以下错误:
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
___cxx_global_var_init.2 in main.cpp.o
"boost::system::generic_category()", referenced from:
boost::system::error_category::std_category::equivalent(int, std::__1::error_condition const&) const in main.cpp.o
boost::system::error_category::std_category::equivalent(std::__1::error_code const&, int) const in main.cpp.o
___cxx_global_var_init in main.cpp.o
___cxx_global_var_init.1 in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [sandbox] Error 1
make[2]: *** [CMakeFiles/sandbox.dir/all] Error 2
make[1]: *** [CMakeFiles/sandbox.dir/rule] Error 2
make: *** [sandbox] Error 2
CMake文件:
cmake_minimum_required(VERSION 3.8)
project(sandbox)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES src/main.cpp)
find_package(Boost)
if (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
endif()
add_executable(sandbox ${SOURCE_FILES})
target_link_libraries (sandbox ${Boost_LIBRARIES})
其他库如boost字符串库工作正常。但我不能使用文件系统库。知道我做错了吗?