I am trying out boost::fiber library, but I couldn't manage to compile code with boost fiber. Therefore I turned into compiling and running boost official examples. I installed latest version of boost library 1.65.1, and installation seems to be fine. I executed following command to compile simple.cpp
g++ -I /usr/local/include/boost/ -L /usr/local/lib/ -lboost_fiber -std=c++11 libs/fiber/examples/simple.cpp
But I get the following complains:
/tmp/ccWQ5ZMf.o: In function `main':
simple.cpp:(.text+0x7b): undefined reference to `boost::fibers::fiber::join()'
/tmp/ccWQ5ZMf.o: In function `boost::context::continuation::~continuation()':
simple.cpp:(.text._ZN5boost7context12continuationD2Ev[_ZN5boost7context12continuationD5Ev]+0x59): undefined reference to `ontop_fcontext'
/tmp/ccWQ5ZMf.o: In function `boost::context::continuation::resume()':
simple.cpp:(.text._ZN5boost7context12continuation6resumeEv[_ZN5boost7context12continuation6resumeEv]+0x68): undefined reference to `jump_fcontext'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::context::context(unsigned long, boost::fibers::type, boost::fibers::launch)':
simple.cpp:(.text._ZN5boost6fibers7contextC2EmNS0_4typeENS0_6launchE[_ZN5boost6fibers7contextC5EmNS0_4typeENS0_6launchE]+0x18): undefined reference to `vtable for boost::fibers::context'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::fiber::get_id() const':
simple.cpp:(.text._ZNK5boost6fibers5fiber6get_idEv[_ZNK5boost6fibers5fiber6get_idEv]+0x3b): undefined reference to `boost::fibers::context::get_id() const'
/tmp/ccWQ5ZMf.o: In function `boost::this_fiber::yield()':
simple.cpp:(.text._ZN5boost10this_fiber5yieldEv[_ZN5boost10this_fiber5yieldEv]+0x5): undefined reference to `boost::fibers::context::active()'
simple.cpp:(.text._ZN5boost10this_fiber5yieldEv[_ZN5boost10this_fiber5yieldEv]+0xd): undefined reference to `boost::fibers::context::yield()'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::fiber::fiber<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int, void, void, void>(void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int)':
simple.cpp:(.text._ZN5boost6fibers5fiberC2IRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEvvvEEOT_DpT0_[_ZN5boost6fibers5fiberC5IRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEvvvEEOT_DpT0_]+0x2c): undefined reference to `boost::context::stack_traits::default_size()'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::fiber::fiber<boost::context::basic_fixedsize_stack<boost::context::stack_traits>, void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>(boost::fibers::launch, std::allocator_arg_t, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int)':
simple.cpp:(.text._ZN5boost6fibers5fiberC2INS_7context21basic_fixedsize_stackINS3_12stack_traitsEEERFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEENS0_6launchESt15allocator_arg_tT_OT0_DpT1_[_ZN5boost6fibers5fiberC5INS_7context21basic_fixedsize_stackINS3_12stack_traitsEEERFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEENS0_6launchESt15allocator_arg_tT_OT0_DpT1_]+0x7f): undefined reference to `boost::fibers::fiber::start_()'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::worker_context<boost::context::basic_fixedsize_stack<boost::context::stack_traits> >(boost::fibers::launch, boost::context::preallocated const&, boost::context::basic_fixedsize_stack<boost::context::stack_traits> const&, void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int)':
simple.cpp:(.text._ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEC2INS_7context21basic_fixedsize_stackINSG_12stack_traitsEEEEENS0_6launchERKNSG_12preallocatedERKT_SB_SD_i[_ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEC5INS_7context21basic_fixedsize_stackINSG_12stack_traitsEEEEENS0_6launchERKNSG_12preallocatedERKT_SB_SD_i]+0x15d): undefined reference to `boost::fibers::context::~context()'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::run_(boost::context::continuation&&)':
simple.cpp:(.text._ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEE4run_EONS_7context12continuationE[_ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEE4run_EONS_7context12continuationE]+0xb5): undefined reference to `boost::fibers::context::terminate()'
/tmp/ccWQ5ZMf.o: In function `void* boost::context::detail::create_context2<boost::context::detail::record<boost::context::continuation, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<std::_Mem_fn<boost::context::continuation (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::*)(boost::context::continuation&&)> (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>*, std::_Placeholder<1>)> >, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<std::_Mem_fn<boost::context::continuation (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::*)(boost::context::continuation&&)> (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>*, std::_Placeholder<1>)> >(boost::context::preallocated, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<std::_Mem_fn<boost::context::continuation (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::*)(boost::context::continuation&&)> (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>*, std::_Placeholder<1>)>&&)':
simple.cpp:(.text._ZN5boost7context6detail15create_context2INS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEES7_SX_EEPvNS0_12preallocatedET0_OT1_[_ZN5boost7context6detail15create_context2INS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEES7_SX_EEPvNS0_12preallocatedET0_OT1_]+0xd8): undefined reference to `make_fcontext'
simple.cpp:(.text._ZN5boost7context6detail15create_context2INS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEES7_SX_EEPvNS0_12preallocatedET0_OT1_[_ZN5boost7context6detail15create_context2INS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEES7_SX_EEPvNS0_12preallocatedET0_OT1_]+0x10f): undefined reference to `jump_fcontext'
/tmp/ccWQ5ZMf.o: In function `void boost::context::detail::context_entry<boost::context::detail::record<boost::context::continuation, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, std::_Bind<std::_Mem_fn<boost::context::continuation (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::*)(boost::context::continuation&&)> (boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>*, std::_Placeholder<1>)> > >(boost::context::detail::transfer_t)':
simple.cpp:(.text._ZN5boost7context6detail13context_entryINS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEEEEvNS1_10transfer_tE[_ZN5boost7context6detail13context_entryINS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEEEEvNS1_10transfer_tE]+0x70): undefined reference to `jump_fcontext'
simple.cpp:(.text._ZN5boost7context6detail13context_entryINS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEEEEvNS1_10transfer_tE[_ZN5boost7context6detail13context_entryINS1_6recordINS0_12continuationENS0_21basic_fixedsize_stackINS0_12stack_traitsEEESt5_BindIFSt7_Mem_fnIMNS_6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEEFS4_OS4_EEPSO_St12_PlaceholderILi1EEEEEEEEvNS1_10transfer_tE]+0xc9): undefined reference to `ontop_fcontext'
/tmp/ccWQ5ZMf.o: In function `boost::fibers::worker_context<void (&)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int), char const*, int>::~worker_context()':
simple.cpp:(.text._ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEED2Ev[_ZN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEED5Ev]+0x20): undefined reference to `boost::fibers::context::~context()'
/tmp/ccWQ5ZMf.o:(.rodata._ZTIN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEE[_ZTIN5boost6fibers14worker_contextIRFvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEJPKciEEE]+0x10): undefined reference to `typeinfo for boost::fibers::context'
collect2: error: ld returned 1 exit status