在构建静态库 uhd 类型并使用内存清理器标志 -fsanitize=memory 与 boost 库 v1.74 链接时,我遇到了错误。
[ 63%] Built target uhd-types
[ 65%] Linking CXX executable ../../bin/unit_tests
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::cpp_regex_traits_implementation<char>::lookup_collatename(char const*, char const*) const':
/root/include/boost/regex/v4/cpp_regex_traits.hpp:680: undefined reference to `boost::re_detail_107400::lookup_default_collate_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fail(boost::regex_constants::error_type, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, long)':
/root/include/boost/regex/v4/basic_regex_parser.hpp:245: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fixup_recursions(boost::re_detail_107400::re_syntax_base*)':
/root/include/boost/regex/v4/basic_regex_creator.hpp:788: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
/usr/bin/ld: /root//include/boost/regex/v4/basic_regex_creator.hpp:877: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::create_startmaps(boost::re_detail_107400::re_syntax_base*)':
/root/include/boost/regex/v4/basic_regex_creator.hpp:943: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
/usr/bin/ld: ../../lib/libuhd-types.a(device_addr.cpp.o): in function `boost::re_detail_107400::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::create_startmap(boost::re_detail_107400::re_syntax_base*, unsigned char*, unsigned int*, unsigned char)':
/root/include/boost/regex/v4/basic_regex_creator.hpp:1156: undefined reference to `boost::regex_error::regex_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::regex_constants::error_type, long)'
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
我已经使用 target_link_libraries 将 uhd 类型链接到提升库。