我下载了boost并构建了它,这并不是第一次,但后来事情开始变得奇怪起来。
起初,我在编译我的项目(使用boost)时遇到以下错误:
/usr/local/include/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
/usr/local/include/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
/usr/local/include/boost/thread/exceptions.hpp:51: undefined reference to `boost::system::system_category()'
/usr/local/include/boost/thread/exceptions.hpp:84: undefined reference to `boost::system::system_category()'
/usr/local/include/boost/thread/pthread/thread_data.hpp:152: undefined reference to `vtable for boost::detail::thread_data_base'
/usr/local/include/boost/thread/pthread/thread_data.hpp:195: undefined reference to `boost::detail::get_current_thread_data()'
/usr/local/include/boost/thread/detail/thread.hpp:179: undefined reference to `boost::thread::start_thread_noexcept()'
/usr/local/include/boost/thread/detail/thread.hpp:741: undefined reference to `boost::thread::native_handle()'
/usr/local/include/boost/thread/detail/thread.hpp:767: undefined reference to `boost::thread::join_noexcept()'
/usr/local/include/boost/thread/detail/thread.hpp:779: undefined reference to `boost::thread::do_try_join_until_noexcept(timespec const&, bool&)'
/usr/local/include/boost/thread/pthread/condition_variable.hpp:84: undefined reference to `boost::this_thread::interruption_point()'
/usr/local/include/boost/thread/detail/thread.hpp:90: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/usr/local/include/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'所以我去检查是否一切就绪,发现我的boost lib文件没有通常的库命名,也就是说,它们看起来就像:libboost_thread.a,libboost_system.a,libboost_date_time.a,而不是-mt,-d等等。
我不记得我是如何构建它的,但如果我尝试运行:
boost_src_dir > ./b2 threading=multi link=static variant=debug,release
我得到了:
error: Name clash for '<pstage/lib>libboost_atomic.a'
error:
error: Tried to build the target twice, with property sets having
error: these incompatible properties:
error:
error: - <debug-symbols>on <inlining>off <optimization>off <runtime-debugging>on <variant>debug
error: - <debug-symbols>off <define>NDEBUG <inlining>full <optimization>speed <runtime-debugging>off <variant>release
error:
error: Please make sure to have consistent requirements for these
error: properties everywhere in your project, especially for install
error: targets.不太确定发生了什么,我之前做过的事情进行得很顺利。
有什么想法吗?
我使用的是linux mint (17.2 x64),boost 1.59,并将其与cmake一起使用,如下所示:
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.36.0 COMPONENTS system thread shared_ptr)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
else()
message("can not find boost")
endif()谢谢。
发布于 2015-10-07 20:12:17
在您的boost代码库中,如果您希望将其放在非默认位置,请确保已使用--prefix=<install directory>运行了./bootstrap.sh。不过,您不需要这个参数。
如果需要,您可以从同一目录运行./b2命令,使用--prefix=<install directory>选项再次安装boost。在尝试执行此操作之前,您可能必须从build/install目录中删除所有以前的构建文件。
此外,请确保您的计算机具有正确的版本。我使用的是http://downloads.sourceforge.net/boost/boost_1_58_0.tar.bz2 (OpenSUSE 13.164位)
https://stackoverflow.com/questions/32991736
复制相似问题