Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined reference errors when I add boost log dependecies

Tags:

c++

boost

I am trying to add boost logging functionality.

But I've got a lot of errors with undefined reference.

D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(core.o): In function `boost::thread_specific_ptr<boost::log::v2s_mt_nt5::core::implementation::thread_data>::~thread_specific_ptr()':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:79: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(core.o): In function `boost::thread_specific_ptr<boost::log::v2s_mt_nt5::core::implementation::thread_data>::get() const':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:84: undefined reference to `boost::detail::get_tss_data(void const*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(core.o): In function `boost::thread_specific_ptr<boost::log::v2s_mt_nt5::core::implementation::thread_data>::reset(boost::log::v2s_mt_nt5::core::implementation::thread_data*)':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:105: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `get':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:84: undefined reference to `boost::detail::get_tss_data(void const*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `reset':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:105: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `get':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:84: undefined reference to `boost::detail::get_tss_data(void const*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `reset':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:105: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(record_ostream.o): In function `~thread_specific_ptr':
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:79: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0/./boost/thread/tss.hpp:79: undefined reference to `boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(severity_level.o): In function `void boost::this_thread::at_thread_exit<boost::_bi::bind_t<boost::_bi::unspecified, boost::checked_deleter<unsigned long long>, boost::_bi::list1<boost::_bi::value<unsigned long long*> > > >(boost::_bi::bind_t<boost::_bi::unspecified, boost::checked_deleter<unsigned long long>, boost::_bi::list1<boost::_bi::value<unsigned long long*> > >)':
D:\c++\boost_1_58_0/./boost/thread/detail/thread.hpp:861: undefined reference to `boost::detail::add_thread_exit_function(boost::detail::thread_exit_function_base*)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(once_block.o): In function `boost::detail::basic_cv_list_entry::wait(boost::detail::timeout)':
D:\c++\boost_1_58_0/./boost/thread/win32/condition_variable.hpp:94: undefined reference to `boost::this_thread::interruptible_wait(void*, boost::detail::timeout)'
D:\c++\boost_1_58_0\bin.v2\libs\log\build\gcc-mingw-5.1.0\debug\link-static\threading-multi/libboost_log-mgw51-mt-d-1_58.a(thread_id.o): In function `at_thread_exit<boost::log::v2s_mt_nt5::aux::this_thread::(anonymous namespace)::id_storage::deleter>':
D:\c++\boost_1_58_0/./boost/thread/detail/thread.hpp:861: undefined reference to `boost::detail::add_thread_exit_function(boost::detail::thread_exit_function_base*)'
collect2.exe: error: ld returned 1 exit status

My linked libraries looks like this.

enter image description here

My include declarations looks like this

enter image description here

Also my boost include folder is located in main x86_64-w64-mingw32 include folder

like image 269
lapots Avatar asked Nov 10 '22 08:11

lapots


1 Answers

Had the same error under Windows 10, Cygwin GCC setup. I had to link boost_thread separately in addition to boost_log and boost_log_setup.

-lboost_log_setup -lboost_log -lboost_thread

I was using BOOST 1.66.

like image 77
jazaman Avatar answered Nov 15 '22 06:11

jazaman