Skip to content

Instantly share code, notes, and snippets.

@n-west
Created Sep 10, 2014
Embed
What would you like to do?
#include <iostream>
#include <boost/thread.hpp>
void workerFunc()
{
std::cout << "Worker: running" << std::endl;
std::cout << "Worker: finished" << std::endl;
}
int main(int argc, char* argv[])
{
std::cout << "main: startup" << std::endl;
boost::thread workerThread(workerFunc);
std::cout << "main: waiting for thread" << std::endl;
workerThread.join();
std::cout << "main: done" << std::endl;
return 0;
}
nathan@vanilla:/opt/code/sandbox/threads $ g++ -lboost_thread -lboost_system bthread.cc
/tmp/ccf6LGdy.o: In function `__static_initialization_and_destruction_0(int, int)':
bthread.cc:(.text+0x13e): undefined reference to `boost::system::generic_category()'
bthread.cc:(.text+0x14a): undefined reference to `boost::system::generic_category()'
bthread.cc:(.text+0x156): undefined reference to `boost::system::system_category()'
/tmp/ccf6LGdy.o: In function `boost::thread_exception::thread_exception(int, char const*)':
bthread.cc:(.text._ZN5boost16thread_exceptionC2EiPKc[_ZN5boost16thread_exceptionC5EiPKc]+0x14): undefined reference to `boost::system::system_category()'
/tmp/ccf6LGdy.o: In function `boost::detail::thread_data_base::thread_data_base()':
bthread.cc:(.text._ZN5boost6detail16thread_data_baseC2Ev[_ZN5boost6detail16thread_data_baseC5Ev]+0x24): undefined reference to `vtable for boost::detail::thread_data_base'
/tmp/ccf6LGdy.o: In function `boost::thread::start_thread()':
bthread.cc:(.text._ZN5boost6thread12start_threadEv[_ZN5boost6thread12start_threadEv]+0x15): undefined reference to `boost::thread::start_thread_noexcept()'
/tmp/ccf6LGdy.o: In function `boost::thread::~thread()':
bthread.cc:(.text._ZN5boost6threadD2Ev[_ZN5boost6threadD5Ev]+0x15): undefined reference to `boost::thread::detach()'
/tmp/ccf6LGdy.o: In function `boost::thread::get_id() const':
bthread.cc:(.text._ZNK5boost6thread6get_idEv[_ZNK5boost6thread6get_idEv]+0x18): undefined reference to `boost::thread::native_handle()'
/tmp/ccf6LGdy.o: In function `boost::thread::join()':
bthread.cc:(.text._ZN5boost6thread4joinEv[_ZN5boost6thread4joinEv]+0x6d): undefined reference to `boost::thread::join_noexcept()'
/tmp/ccf6LGdy.o: In function `boost::detail::thread_data<void (*)()>::~thread_data()':
bthread.cc:(.text._ZN5boost6detail11thread_dataIPFvvEED2Ev[_ZN5boost6detail11thread_dataIPFvvEED5Ev]+0x1f): undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/tmp/ccf6LGdy.o:(.rodata._ZTIN5boost6detail11thread_dataIPFvvEEE[_ZTIN5boost6detail11thread_dataIPFvvEEE]+0x10): undefined reference to `typeinfo for boost::detail::thread_data_base'
collect2: error: ld returned 1 exit status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment