c++ - 对 boost::filesystem::path_traits::convert 的 undefined reference

标签 c++ boost

我正在尝试使用 cmake 编译程序,并且看到以下链接器错误:

/home/quant/bin/boost_1_61_0/stage/lib/libboost_log_setup.so: undefined reference to boost::filesystem::path_traits::convert(wchar_t const*, wchar_t const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::codecvt<wchar_t, char, __mbstate_t> const&)' /home/quant/bin/boost_1_61_0/stage/lib/libboost_log.so: undefined reference to boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__cxx11::basic_string, std::allocator >&)'

链接器命令 ninja生成的内容如下所示:

g++ -pthread -DBOOST_ALL_DYN_LINK
utility/test/CMakeFiles/utilityTest.dir/loadCSVTests.cpp.o utility/test/CMakeFiles/utilityTest.dir/main.cpp.o utility/test/CMakeFiles/utilityTest.dir/randomDeviceTests.cpp.o -o utility/test/utilityTest -rdynamic /home/quant/bin/boost_1_61_0/stage/lib/libboost_thread.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_program_options.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_serialization.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_unit_test_framework.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_system.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_log.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_log_setup.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_filesystem.so utility/lib/libutilityLib.a utility/testLib/libutilityTestLib.a utility/lib/libutilityLib.a /home/quant/bin/boost_1_61_0/stage/lib/libboost_thread.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_program_options.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_serialization.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_unit_test_framework.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_system.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_log.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_log_setup.so /home/quant/bin/boost_1_61_0/stage/lib/libboost_filesystem.so -Wl,-rpath,/home/quant/bin/boost_1_61_0/stage/lib

如您所见,我链接到 boost_filesystemboost_system ,所以这与 this SO post 中提到的问题不同。 (还有许多其他人喜欢它)。

我正在使用boost 1.61 ,我用 gcc 5.3 编译(与我编译程序的编译器相同)。

我做错了什么?

最佳答案

我遇到了类似的问题,这可能是因为 gcc 5.1 引入了新的 ABI。

https://github.com/openframeworks/openFrameworks/issues/4203

我通过将“add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)”添加到 CMakeLists.txt 来修复我的问题

关于c++ - 对 boost::filesystem::path_traits::convert 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39475716/

相关文章:

c++ - 添加高斯噪声

c++ - "Body requirements not met"将请求传递给 c++ 中的方法(Boost Beast 库)

c++ - 链表 C++ 删除节点

c++ - C++ 中的 "error: Expected a type, got ' 类名 '"

c++ - 元编程继承限制

debugging - boost 测试 : how to debug tested code?

C++ Boost 图库 : outputting custom vertex properties

c++ - 无法访问 vector 大小

c++ - OPERATOR_BRACKET_IS_NOT_SUPPORTED 在 boost::bimap 上

c++ - 提取日期字符串并确定哪个更早