I am trying to compile my C++ project on Linux x64 with boost libraries 1.57.
This project is compiled with scons and I successfully compiled it on my Arch Linux, but this time failed on a Ubuntu machine.
I added -lboost_coroutine
flag for linking but the error "undefined reference" still existed.
/usr/bin/g++ -o build/gcc.release/app -pthread -g
build/gcc.release/src/han/unity/rpcx.o
-lpthread -lz -lboost_coroutine -lboost_context -lboost_date_time
build/gcc.release/src/han/unity/rpcx.o: In function `attributes':
/usr/local/include/boost/coroutine/attributes.hpp:31: undefined reference
to `boost::coroutines::stack_traits::default_size()'
I noticed that the attributes.hpp is exactly one of the boost coroutine header files. And I tried with nm to boost coroutine libs and it seems no problem.
nm /usr/local/lib/libboost_coroutine.a | grep "default_size"
0000000000000170 T _ZN5boost10coroutines12stack_traits12default_sizeEv
I searched the possible reasons for this error and most are about the order of linker flags. And in this case the rpcx.o depends on boost_coroutine, so this appears in front.
What else could be the causes?
libboost_thread
after libboost_coroutine. – WaistclothVERBOSE=1
, you should see the commands that are used to build your app. – Waistcloth