<small id='FDsw1'></small><noframes id='FDsw1'>

      <i id='FDsw1'><tr id='FDsw1'><dt id='FDsw1'><q id='FDsw1'><span id='FDsw1'><b id='FDsw1'><form id='FDsw1'><ins id='FDsw1'></ins><ul id='FDsw1'></ul><sub id='FDsw1'></sub></form><legend id='FDsw1'></legend><bdo id='FDsw1'><pre id='FDsw1'><center id='FDsw1'></center></pre></bdo></b><th id='FDsw1'></th></span></q></dt></tr></i><div id='FDsw1'><tfoot id='FDsw1'></tfoot><dl id='FDsw1'><fieldset id='FDsw1'></fieldset></dl></div>
        • <bdo id='FDsw1'></bdo><ul id='FDsw1'></ul>
        <tfoot id='FDsw1'></tfoot><legend id='FDsw1'><style id='FDsw1'><dir id='FDsw1'><q id='FDsw1'></q></dir></style></legend>

        链接 boost 日志教程时的链接器错误(未定义的参考)

        时间:2023-06-29

        <small id='O8XPC'></small><noframes id='O8XPC'>

          <bdo id='O8XPC'></bdo><ul id='O8XPC'></ul>
            <i id='O8XPC'><tr id='O8XPC'><dt id='O8XPC'><q id='O8XPC'><span id='O8XPC'><b id='O8XPC'><form id='O8XPC'><ins id='O8XPC'></ins><ul id='O8XPC'></ul><sub id='O8XPC'></sub></form><legend id='O8XPC'></legend><bdo id='O8XPC'><pre id='O8XPC'><center id='O8XPC'></center></pre></bdo></b><th id='O8XPC'></th></span></q></dt></tr></i><div id='O8XPC'><tfoot id='O8XPC'></tfoot><dl id='O8XPC'><fieldset id='O8XPC'></fieldset></dl></div>

            <tfoot id='O8XPC'></tfoot>
            <legend id='O8XPC'><style id='O8XPC'><dir id='O8XPC'><q id='O8XPC'></q></dir></style></legend>
                  <tbody id='O8XPC'></tbody>
                  本文介绍了链接 boost 日志教程时的链接器错误(未定义的参考)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经通过 yum 在 Fedora 20 上安装了 boost 并且正在尝试一些简单的例子.但是,我无法编译 日志教程中的第一个示例.

                  I have installed boost on Fedora 20 via yum and am trying some simple examples. However I have trouble to compile the first example from the logging tutorial.

                  使用 g++ -c boosttest.cc 编译工作正常,但是当我尝试将其链接到时出现很多错误

                  Compiling with g++ -c boosttest.cc works fine, but I get lot's of errors when I try to link it with

                  g++ boosttest.o -o boosttest -lboost_log -lpthread
                  

                  完整的错误日志:

                  boosttest.o: In function `main':
                  boosttest.cc:(.text+0x44): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
                  boosttest.cc:(.text+0x9a): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
                  boosttest.cc:(.text+0x167): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
                  boosttest.cc:(.text+0x1bd): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
                  boosttest.cc:(.text+0x28a): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
                  boosttest.o:boosttest.cc:(.text+0x2e0): more undefined references to `boost::log::v2s_mt_posix::trivial::logger::get()' follow
                  boosttest.o: In function `boost::log::v2s_mt_posix::record::reset()':
                  boosttest.cc:(.text._ZN5boost3log12v2s_mt_posix6record5resetEv[_ZN5boost3log12v2s_mt_posix6record5resetEv]+0x18): undefined reference to `boost::log::v2s_mt_posix::record_view::public_data::destroy(boost::log::v2s_mt_posix::record_view::public_data const*)'
                  boosttest.o: In function `boost::log::v2s_mt_posix::record boost::log::v2s_mt_posix::sources::basic_composite_logger<char, boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>, boost::log::v2s_mt_posix::sources::multi_thread_model<boost::log::v2s_mt_posix::aux::light_rw_mutex>, boost::log::v2s_mt_posix::sources::features<boost::log::v2s_mt_posix::sources::severity<boost::log::v2s_mt_posix::trivial::severity_level>, void, void, void, void, void, void, void, void, void> >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> const&)':
                  boosttest.cc:(.text._ZN5boost3log12v2s_mt_posix7sources22basic_composite_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEENS2_8featuresINS2_8severityIS6_EEvvvvvvvvvEEE11open_recordINS_9parameter3aux15tagged_argumentINS1_8keywords3tag8severityEKS6_EEEENS1_6recordERKT_[_ZN5boost3log12v2s_mt_posix7sources22basic_composite_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEENS2_8featuresINS2_8severityIS6_EEvvvvvvvvvEEE11open_recordINS_9parameter3aux15tagged_argumentINS1_8keywords3tag8severityEKS6_EEEENS1_6recordERKT_]+0x1e): undefined reference to `boost::log::v2s_mt_posix::core::get_logging_enabled() const'
                  boosttest.o: In function `boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::~record_pump()':
                  boosttest.cc:(.text._ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEED2Ev[_ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEED5Ev]+0x2c): undefined reference to `boost::log::v2s_mt_posix::aux::unhandled_exception_count()'
                  boosttest.o: In function `boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::record_pump(boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>&, boost::log::v2s_mt_posix::record&)':
                  boosttest.cc:(.text._ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEEC2ERS8_RNS1_6recordE[_ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEEC5ERS8_RNS1_6recordE]+0x1d): undefined reference to `boost::log::v2s_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log::v2s_mt_posix::record&)'
                  boosttest.cc:(.text._ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEEC2ERS8_RNS1_6recordE[_ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEEC5ERS8_RNS1_6recordE]+0x28): undefined reference to `boost::log::v2s_mt_posix::aux::unhandled_exception_count()'
                  boosttest.o: In function `boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::auto_release::~auto_release()':
                  boosttest.cc:(.text._ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEE12auto_releaseD2Ev[_ZN5boost3log12v2s_mt_posix3aux11record_pumpINS1_7sources18severity_logger_mtINS1_7trivial14severity_levelEEEE12auto_releaseD5Ev]+0xf): undefined reference to `boost::log::v2s_mt_posix::aux::stream_provider<char>::release_compound(boost::log::v2s_mt_posix::aux::stream_provider<char>::stream_compound*)'
                  boosttest.o: In function `boost::log::v2s_mt_posix::sources::aux::severity_level<boost::log::v2s_mt_posix::trivial::severity_level>::set_value(boost::log::v2s_mt_posix::trivial::severity_level)':
                  boosttest.cc:(.text._ZN5boost3log12v2s_mt_posix7sources3aux14severity_levelINS1_7trivial14severity_levelEE9set_valueES6_[_ZN5boost3log12v2s_mt_posix7sources3aux14severity_levelINS1_7trivial14severity_levelEE9set_valueES6_]+0x7): undefined reference to `boost::log::v2s_mt_posix::sources::aux::get_severity_level()'
                  boosttest.o: In function `boost::log::v2s_mt_posix::record boost::log::v2s_mt_posix::sources::basic_logger<char, boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>, boost::log::v2s_mt_posix::sources::multi_thread_model<boost::log::v2s_mt_posix::aux::light_rw_mutex> >::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> const&)':
                  boosttest.cc:(.text._ZN5boost3log12v2s_mt_posix7sources12basic_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEEE20open_record_unlockedINS_9parameter3aux15tagged_argumentINS1_8keywords3tag8severityEKS6_EEEENS1_6recordERKT_[_ZN5boost3log12v2s_mt_posix7sources12basic_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEEE20open_record_unlockedINS_9parameter3aux15tagged_argumentINS1_8keywords3tag8severityEKS6_EEEENS1_6recordERKT_]+0x2a): undefined reference to `boost::log::v2s_mt_posix::core::open_record(boost::log::v2s_mt_posix::attribute_set const&)'
                  boosttest.o: In function `boost::log::v2s_mt_posix::sources::basic_logger<char, boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>, boost::log::v2s_mt_posix::sources::multi_thread_model<boost::log::v2s_mt_posix::aux::light_rw_mutex> >::push_record_unlocked(boost::rv<boost::log::v2s_mt_posix::record>&)':
                  boosttest.cc:(.text._ZN5boost3log12v2s_mt_posix7sources12basic_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEEE20push_record_unlockedERNS_2rvINS1_6recordEEE[_ZN5boost3log12v2s_mt_posix7sources12basic_loggerIcNS2_18severity_logger_mtINS1_7trivial14severity_levelEEENS2_18multi_thread_modelINS1_3aux14light_rw_mutexEEEE20push_record_unlockedERNS_2rvINS1_6recordEEE]+0x36): undefined reference to `boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&)'
                  collect2: error: ld returned 1 exit status
                  

                  我错过了什么?我做错了什么?

                  What am I missing? What am I doing wrong?

                  EDIT 1: -lboost_log -lpthread 的顺序对输出没有影响.还有一个非常相似的问题,但解决方案不起作用给我.以下也失败并出现相同的错误:

                  EDIT 1: The order of -lboost_log -lpthread makes no difference in the output. There is also a very similar question, but the solution does not work for me. The following also fails with the same errors:

                  g++ -DBOOST_LOG_DYN_LINK boosttest.o -o boosttest -lboost_log -lpthread
                  

                  推荐答案

                  只需添加一行

                  #define BOOST_LOG_DYN_LINK 1
                  

                  作为boosttest.cc的第一行.

                  或者,您可以将 -DBOOST_LOG_DYN_LINK 添加到您的编译步骤(不是您在问题中发布的链接步骤):

                  Alternatively, you can add -DBOOST_LOG_DYN_LINK to you compilation step (not the linking step, as you posted in the question):

                  g++ -std=c++11 -Wall -pedantic -g -O0 -DBOOST_LOG_DYN_LINK  -c boosttest.cc
                  g++  boosttest.o -lpthread -lboost_log -o boosttest
                  

                  这篇关于链接 boost 日志教程时的链接器错误(未定义的参考)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何转义字符串以在 Boost Regex 中使用 下一篇:如何从 std::map 中过滤项目?

                  相关文章

                    <bdo id='Egq7d'></bdo><ul id='Egq7d'></ul>
                  1. <i id='Egq7d'><tr id='Egq7d'><dt id='Egq7d'><q id='Egq7d'><span id='Egq7d'><b id='Egq7d'><form id='Egq7d'><ins id='Egq7d'></ins><ul id='Egq7d'></ul><sub id='Egq7d'></sub></form><legend id='Egq7d'></legend><bdo id='Egq7d'><pre id='Egq7d'><center id='Egq7d'></center></pre></bdo></b><th id='Egq7d'></th></span></q></dt></tr></i><div id='Egq7d'><tfoot id='Egq7d'></tfoot><dl id='Egq7d'><fieldset id='Egq7d'></fieldset></dl></div>

                    <small id='Egq7d'></small><noframes id='Egq7d'>

                    <tfoot id='Egq7d'></tfoot>
                  2. <legend id='Egq7d'><style id='Egq7d'><dir id='Egq7d'><q id='Egq7d'></q></dir></style></legend>