zoukankan      html  css  js  c++  java
  • boost中g++ 链接undefined reference to `boost::system::generic_category()问题

    编译错误如下:

    g++ -std=c++11  tcp_session.cpp tcp_server.cpp test.cpp -o test -pthread
    /tmp/ccv4rZkD.o: In function `__static_initialization_and_destruction_0(int, int)':
    tcp_session.cpp:(.text+0x670): undefined reference to `boost::system::generic_category()'
    tcp_session.cpp:(.text+0x67c): undefined reference to `boost::system::generic_category()'
    tcp_session.cpp:(.text+0x688): undefined reference to `boost::system::system_category()'
    /tmp/ccv4rZkD.o: In function `boost::system::error_code::error_code()':
    tcp_session.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
    /tmp/ccv4rZkD.o: In function `boost::asio::error::get_system_category()':
    tcp_session.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to `boost::system::system_category()'
    /tmp/cctVI799.o: In function `tcp_server::start_accept()':
    tcp_server.cpp:(.text+0x18e): undefined reference to `tcp_session::socket()'
    /tmp/cctVI799.o: In function `__static_initialization_and_destruction_0(int, int)':
    tcp_server.cpp:(.text+0x2fc): undefined reference to `boost::system::generic_category()'
    tcp_server.cpp:(.text+0x308): undefined reference to `boost::system::generic_category()'
    tcp_server.cpp:(.text+0x314): undefined reference to `boost::system::system_category()'
    /tmp/cctVI799.o: In function `boost::thread_exception::thread_exception(int, char const*)':
    tcp_server.cpp:(.text._ZN5boost16thread_exceptionC2EiPKc[_ZN5boost16thread_exceptionC5EiPKc]+0x23): undefined reference to `boost::system::system_category()'
    /tmp/cctVI799.o: In function `boost::condition_error::condition_error(int, char const*)':

    添加链接库  -lboost_system, 问题解决。

    若还有其他查找不到的,可以去安装路径,查找相应的库文件,编译时加载。

    eg:

    /home/program/boost_1_67_0$ find . -name *.so
    ./stage/lib/libboost_log_setup.so
    ./stage/lib/libboost_chrono.so
    ./stage/lib/libboost_numpy27.so
    ./stage/lib/libboost_coroutine.so
    ./stage/lib/libboost_atomic.so
    ./stage/lib/libboost_type_erasure.so
    ./stage/lib/libboost_serialization.so
    ./stage/lib/libboost_math_c99f.so
    ./stage/lib/libboost_regex.so
    ./stage/lib/libboost_container.so
    ./stage/lib/libboost_filesystem.so
    ./stage/lib/libboost_thread.so
    ./stage/lib/libboost_math_tr1l.so
    ./stage/lib/libboost_random.so
    ./stage/lib/libboost_program_options.so
    ./stage/lib/libboost_signals.so
    ./stage/lib/libboost_locale.so
    ./stage/lib/libboost_unit_test_framework.so
    ./stage/lib/libboost_wave.so
    ./stage/lib/libboost_stacktrace_backtrace.so
    ./stage/lib/libboost_date_time.so
    ./stage/lib/libboost_iostreams.so
    ./stage/lib/libboost_stacktrace_addr2line.so
    ./stage/lib/libboost_log.so
    ./stage/lib/libboost_stacktrace_noop.so
    ./stage/lib/libboost_math_c99.so
    ./stage/lib/libboost_prg_exec_monitor.so
    ./stage/lib/libboost_math_c99l.so
    ./stage/lib/libboost_graph.so
    ./stage/lib/libboost_timer.so
    ./stage/lib/libboost_stacktrace_basic.so
    ./stage/lib/libboost_python27.so
    ./stage/lib/libboost_context.so
    ./stage/lib/libboost_math_tr1f.so
    ./stage/lib/libboost_math_tr1.so
    ./stage/lib/libboost_system.so
    ./stage/lib/libboost_wserialization.so
    ./stage/lib/libboost_contract.so

    例如,线程相关,  -lboost_thread

  • 相关阅读:
    SAP应用真的不性感么
    从ABAP Netweaver的SICF到SAP Kyma的Lambda Function
    WordPress,SAP Kyma和微信三者的集成
    SAP官方发布的ABAP编程规范
    SAP官方提供的人脸识别API
    第三方应用如何在SAP Kyma上进行服务注册
    Just a Hook
    Backward Digit Sums
    Balanced Substring
    hdu 1358 Period
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/11837629.html
Copyright © 2011-2022 走看看