Package: libboost-thread-dev Version: 1.74.0.3 Severity: important X-Debbugs-Cc: the.ju...@gmail.com
Dear Maintainer, I was trying to compile a very basic boost-thread program. I used the following command. g++ --std=c++14 -pthread -lboost_thread -lboost_system -o ./boost_thread_example.out ./boost_thread_example.cpp and the contents of the ./boost_thread_example.cpp are as follows ------------------------------------------------------------------------- #include <boost/thread.hpp> #include <boost/chrono.hpp> #include <iostream> void wait(int seconds) { boost::this_thread::sleep_for(boost::chrono::seconds{seconds}); } void thread() { for (int i = 0; i < 5; ++i) { wait(1); std::cout << i << '\n'; } } int main() { boost::thread t{thread}; t.join(); } ------------------------------------------------------------------------- The error message are as follows. -------------------------------------------------------------------------- /usr/bin/ld: /tmp/ccBDR6eQ.o: warning: relocation against `_ZTVN5boost6detail16thread_data_baseE' in read-only section `.text._ZN5boost6detail16thread_data_baseC2Ev[_ZN5boost6detail16thread_data_baseC5Ev]' /usr/bin/ld: /tmp/ccBDR6eQ.o: in function `boost::detail::thread_data_base::thread_data_base()': boost_thread_example.cpp:(.text._ZN5boost6detail16thread_data_baseC2Ev[_ZN5boost6detail16thread_data_baseC5Ev]+0x20): undefined reference to `vtable for boost::detail::thread_data_base' /usr/bin/ld: /tmp/ccBDR6eQ.o: in function `boost::detail::interruption_checker::interruption_checker(pthread_mutex_t*, pthread_cond_t*)': boost_thread_example.cpp:(.text._ZN5boost6detail20interruption_checkerC2EP15pthread_mutex_tP14pthread_cond_t[_ZN5boost6detail20interruption_checkerC5EP15pthread_mutex_tP14pthread_cond_t]+0x16): undefined reference to `boost::detail::get_current_thread_data()' /usr/bin/ld: /tmp/ccBDR6eQ.o: in function `boost::thread::start_thread()': boost_thread_example.cpp:(.text._ZN5boost6thread12start_threadEv[_ZN5boost6thread12start_threadEv]+0x15): undefined reference to `boost::thread::start_thread_noexcept()' /usr/bin/ld: /tmp/ccBDR6eQ.o: in function `boost::thread::~thread()': boost_thread_example.cpp:(.text._ZN5boost6threadD2Ev[_ZN5boost6threadD5Ev]+0x14): undefined reference to `boost::thread::detach()' /usr/bin/ld: /tmp/ccBDR6eQ.o: in function `boost::thread::get_id() const': boost_thread_example.cpp:(.text._ZNK5boost6thread6get_idEv[_ZNK5boost6thread6get_idEv]+0x14): undefined reference to `boost::thread::native_handle()' /usr/bin/ld: /tmp/ccBDR6eQ.o: in function `boost::thread::join()': boost_thread_example.cpp:(.text._ZN5boost6thread4joinEv[_ZN5boost6thread4joinEv]+0x69): undefined reference to `boost::thread::join_noexcept()' /usr/bin/ld: /tmp/ccBDR6eQ.o: in function `boost::condition_variable::do_wait_until(boost::unique_lock<boost::mutex>&, boost::detail::mono_platform_timepoint const&)': boost_thread_example.cpp:(.text._ZN5boost18condition_variable13do_wait_untilERNS_11unique_lockINS_5mutexEEERKNS_6detail23mono_platform_timepointE[_ZN5boost18condition_variable13do_wait_untilERNS_11unique_lockINS_5mutexEEERKNS_6detail23mono_platform_timepointE]+0x107): undefined reference to `boost::this_thread::interruption_point()' /usr/bin/ld: /tmp/ccBDR6eQ.o: in function `bool boost::condition_variable::wait_for<long, boost::ratio<1l, 1l>, bool (*)()>(boost::unique_lock<boost::mutex>&, boost::chrono::duration<long, boost::ratio<1l, 1l> > const&, bool (*)())': boost_thread_example.cpp:(.text._ZN5boost18condition_variable8wait_forIlNS_5ratioILl1ELl1EEEPFbvEEEbRNS_11unique_lockINS_5mutexEEERKNS_6chrono8durationIT_T0_EET1_[_ZN5boost18condition_variable8wait_forIlNS_5ratioILl1ELl1EEEPFbvEEEbRNS_11unique_lockINS_5mutexEEERKNS_6chrono8durationIT_T0_EET1_]+0x21): undefined reference to `boost::chrono::steady_clock::now()' /usr/bin/ld: /tmp/ccBDR6eQ.o: in function `boost::detail::thread_data<void (*)()>::~thread_data()': boost_thread_example.cpp:(.text._ZN5boost6detail11thread_dataIPFvvEED2Ev[_ZN5boost6detail11thread_dataIPFvvEED5Ev]+0x22): undefined reference to `boost::detail::thread_data_base::~thread_data_base()' /usr/bin/ld: /tmp/ccBDR6eQ.o:(.data.rel.ro._ZTIN5boost6detail11thread_dataIPFvvEEE[_ZTIN5boost6detail11thread_dataIPFvvEEE]+0x10): undefined reference to `typeinfo for boost::detail::thread_data_base' /usr/bin/ld: warning: creating DT_TEXTREL in a PIE collect2: error: ld returned 1 exit status --------------------------------------------------------------------------- My g++ version is: g++ (Debian 10.2.1-6) 10.2.1 20210110 Other boost-libraries such as asio appear to be working well. Many thanks. -- System Information: Debian Release: 11.2 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-9-amd64 (SMP w/2 CPU threads) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages libboost-thread-dev depends on: ii libboost-thread1.74-dev 1.74.0-9 libboost-thread-dev recommends no packages. libboost-thread-dev suggests no packages.