本文介绍了未定义的引用`提振:: log_mt_posix :: basic_attribute_set<焦炭> ::〜basic_attribute_set()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新手问题...我尝试的第一次加速,因为我要试驾的库。我建这个测试程序...

Newbie question... I'm trying out Boost for the first time because I want to test drive the Boost Log library. I built this test program...

#include <boost/log/trivial.hpp>
#include <iostream>

int fibonacci(int num) {
    int i;
    int a = 1;
    int b = 1;

    for (i = 2; i <= num; ++i) {
        BOOST_LOG_TRIVIAL(info) << "Iteration " << i << " (a = " << a << ", b = " << b << ")...";
        b = a + b;
        a = b - a;
    }

    return a;
}

int main() {
    std::cout << "8th fibonacci number: " << fibonacci(8) << std::endl;
    return 0;
}

编译数据:

**** Build of configuration Debug for project LoggingCpp ****

make all 
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -lpthread -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
Finished building: ../main.cpp

Building target: LoggingCpp
Invoking: GCC C++ Linker
g++ -lpthread -o"LoggingCpp"  ./main.o   
./main.o: In function `~basic_logger':
/usr/include/boost/log/sources/basic_logger.hpp:90: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::~basic_attribute_set()'
./main.o: In function `boost::log_mt_posix::trivial::logger::construct_logger()':
/usr/include/boost/log/trivial.hpp:102: undefined reference to `boost::log_mt_posix::trivial::aux::init()'
./main.o: In function `void boost::call_once<void (*)()>(boost::once_flag&, void (*)())':
/usr/include/boost/thread/pthread/once.hpp:51: undefined reference to `boost::detail::get_once_per_thread_epoch()'
/usr/include/boost/thread/pthread/once.hpp:55: undefined reference to `boost::detail::once_epoch_mutex'
/usr/include/boost/thread/pthread/once.hpp:66: undefined reference to `boost::detail::once_epoch_mutex'
/usr/include/boost/thread/pthread/once.hpp:77: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:77: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:77: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:78: undefined reference to `boost::detail::once_epoch_cv'
/usr/include/boost/thread/pthread/once.hpp:84: undefined reference to `boost::detail::once_epoch_mutex'
/usr/include/boost/thread/pthread/once.hpp:84: undefined reference to `boost::detail::once_epoch_cv'
/usr/include/boost/thread/pthread/once.hpp:88: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:73: undefined reference to `boost::detail::once_epoch_cv'
./main.o: In function `record_pump':
/usr/include/boost/log/sources/record_ostream.hpp:293: undefined reference to `boost::log_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log_mt_posix::basic_record<char> const&)'
./main.o: In function `~auto_release':
/usr/include/boost/log/sources/record_ostream.hpp:280: undefined reference to `boost::log_mt_posix::aux::stream_provider<char>::release_compound(boost::log_mt_posix::aux::stream_provider<char>::stream_compound*)'
./main.o: In function `boost::log_mt_posix::sources::aux::logger_singleton<boost::log_mt_posix::trivial::logger>::init_instance()':
/usr/include/boost/log/sources/global_logger_storage.hpp:126: undefined reference to `boost::log_mt_posix::sources::aux::global_storage<char>::get_or_init(std::type_info const&, boost::function0<boost::shared_ptr<boost::log_mt_posix::sources::aux::logger_holder_base> > const&)'
/usr/include/boost/log/sources/global_logger_storage.hpp:147: undefined reference to `boost::log_mt_posix::odr_violation::throw_(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./main.o: In function `boost::log_mt_posix::sources::aux::severity_level<boost::log_mt_posix::trivial::severity_level>::set_value(boost::log_mt_posix::trivial::severity_level)':
/usr/include/boost/log/sources/severity_feature.hpp:95: undefined reference to `boost::log_mt_posix::sources::aux::set_severity_level(int)'
./main.o: In function `boost::log_mt_posix::basic_record<char> boost::log_mt_posix::sources::basic_logger<char, boost::log_mt_posix::sources::severity_logger_mt<boost::log_mt_posix::trivial::severity_level>, boost::log_mt_posix::sources::multi_thread_model<boost::log_mt_posix::aux::light_rw_mutex> >::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log_mt_posix::keywords::tag::severity, boost::log_mt_posix::trivial::severity_level const> >(boost::parameter::aux::tagged_argument<boost::log_mt_posix::keywords::tag::severity, boost::log_mt_posix::trivial::severity_level const> const&)':
/usr/include/boost/log/sources/basic_logger.hpp:269: undefined reference to `boost::log_mt_posix::basic_core<char>::open_record(boost::log_mt_posix::basic_attribute_set<char> const&)'
./main.o: In function `boost::log_mt_posix::sources::basic_logger<char, boost::log_mt_posix::sources::severity_logger_mt<boost::log_mt_posix::trivial::severity_level>, boost::log_mt_posix::sources::multi_thread_model<boost::log_mt_posix::aux::light_rw_mutex> >::push_record_unlocked(boost::log_mt_posix::basic_record<char> const&)':
/usr/include/boost/log/sources/basic_logger.hpp:280: undefined reference to `boost::log_mt_posix::basic_core<char>::push_record(boost::log_mt_posix::basic_record<char> const&)'
./main.o: In function `basic_logger<boost::parameter::aux::tagged_argument<boost::log_mt_posix::keywords::tag::severity, const boost::log_mt_posix::trivial::severity_level> >':
/usr/include/boost/log/sources/basic_logger.hpp:145: undefined reference to `boost::log_mt_posix::basic_core<char>::get()'
/usr/include/boost/log/sources/basic_logger.hpp:145: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::basic_attribute_set()'
./main.o: In function `~pair':
/usr/include/c++/4.5/bits/stl_pair.h:72: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
/usr/include/c++/4.5/bits/stl_pair.h:72: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
./main.o: In function `basic_logger':
/usr/include/boost/log/sources/basic_logger.hpp:135: undefined reference to `boost::log_mt_posix::basic_core<char>::get()'
/usr/include/boost/log/sources/basic_logger.hpp:135: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::basic_attribute_set(boost::log_mt_posix::basic_attribute_set<char> const&)'
./main.o: In function `boost::log_mt_posix::basic_attribute_set<char>::reference_proxy::operator=(boost::shared_ptr<boost::log_mt_posix::attribute> const&) const':
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::basic_slim_string(char const*, unsigned long)'
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::insert(boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> > const&, boost::shared_ptr<boost::log_mt_posix::attribute> const&)'
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
./main.o: In function `pair<std::basic_string<char>, boost::shared_ptr<boost::log_mt_posix::attribute> >':
/usr/include/c++/4.5/bits/stl_pair.h:116: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::basic_slim_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./main.o: In function `boost::log_mt_posix::basic_attribute_set<char>::insert(std::pair<boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> > const, boost::shared_ptr<boost::log_mt_posix::attribute> > const&)':
/usr/include/boost/log/attributes/attribute_set.hpp:507: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::insert(boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> > const&, boost::shared_ptr<boost::log_mt_posix::attribute> const&)'
./main.o: In function `boost::log_mt_posix::sources::aux::severity_level<boost::log_mt_posix::trivial::severity_level>::dispatch(boost::log_mt_posix::type_dispatcher&)':
/usr/include/boost/log/sources/severity_feature.hpp:105: undefined reference to `boost::log_mt_posix::sources::aux::get_severity_level()'
./main.o: In function `boost::log_mt_posix::sources::aux::severity_level<boost::log_mt_posix::trivial::severity_level>::detach_from_thread()':
/usr/include/boost/log/sources/severity_feature.hpp:118: undefined reference to `boost::log_mt_posix::sources::aux::get_severity_level()'
collect2: ld returned 1 exit status
make: *** [LoggingCpp] Error 1

我是否安装升压登录是否有误?我失去了至关重要的库?难道我省略了必要的连接器选项?

Did I install Boost Log incorrectly? Am I missing crucial libraries? Did I omit necessary linker flags?

推荐答案

看起来你还没有建立日志?

It looks like you haven't built log?

一旦您复制日志头文件等成助推的发行相应的文件夹(保持相同的结构,即头文件合并到头部,libs文件夹到您的提振发行的libs文件夹等)你仍然需要建立升压,然后像约翰提到,链接反对。这就是为什么你的链接上面提到的点,你的标准升压构建说明。

Once you've copied the log header files, etc into the corresponding folders in your boost distro (keep the same structure i.e. merge the headers to the headers, the libs folder into the libs folder of your boost distro, etc), you still need to build boost and then like John mentioned, link against it. That's why the link you referred to above points you to the standard boost build instructions.

这是前一段时间,但AFAIR在Linux上,你只需在提振文件夹的根目录运行 ./的bjam

It's a while ago, but AFAIR on linux you simply run ./bjam in the root of your boost folder.

这篇关于未定义的引用`提振:: log_mt_posix :: basic_attribute_set&LT;焦炭&GT; ::〜basic_attribute_set()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 00:31