Вопрос новичка ... Я впервые пробую Boost, потому что хочу протестировать библиотеку Boost Log .Я построил эту тестовую программу ...
#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
О синтаксисе Boost Log
Установил ли я Boost Logнеправильно?Я скучаю по важным библиотекам?Я пропустил необходимые флаги компоновщика?