c++ - Build with Boost.build and link against boost -
as starting project boost lib, seems set-up isn't working :
main.cpp :
#include <boost/asio.hpp> int main(int argc, char* argv[]) { boost::asio::io_service io_service_; return 0; } jamfile :
exe node : main.cpp ; bjam produce :
...found 30 targets... ...updating 2 targets... gcc.compile.c++ bin/gcc-4.7.0/debug/main.o gcc.link bin/gcc-4.7.0/debug/node bin/gcc-4.7.0/debug/main.o: in function `__static_initialization_and_destruction_0': /usr/include/boost/system/error_code.hpp:214: undefined reference `boost::system::generic_category()' /usr/include/boost/system/error_code.hpp:215: undefined reference `boost::system::generic_category()' /usr/include/boost/system/error_code.hpp:216: undefined reference `boost::system::system_category()' bin/gcc-4.7.0/debug/main.o: in function `boost::system::error_code::error_code()': /usr/include/boost/system/error_code.hpp:315: undefined reference `boost::system::system_category()' bin/gcc-4.7.0/debug/main.o: in function `boost::asio::error::get_system_category()': /usr/include/boost/asio/error.hpp:216: undefined reference `boost::system::system_category()' bin/gcc-4.7.0/debug/main.o: in function `boost::asio::detail::posix_tss_ptr_create(unsigned int&)': /usr/include/boost/asio/detail/impl/posix_tss_ptr.ipp:34: undefined reference `pthread_key_create' bin/gcc-4.7.0/debug/main.o: in function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service, boost::asio::detail::task_io_service::thread_info>::context>::~posix_tss_ptr()': /usr/include/boost/asio/detail/posix_tss_ptr.hpp:48: undefined reference `pthread_key_delete' bin/gcc-4.7.0/debug/main.o: in function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::strand_service::strand_impl, unsigned char>::context>::~posix_tss_ptr()': /usr/include/boost/asio/detail/posix_tss_ptr.hpp:48: undefined reference `pthread_key_delete' collect2: error: ld returned 1 exit status "g++" -o "bin/gcc-4.7.0/debug/node" -wl,--start-group "bin/gcc-4.7.0/debug/main.o" -wl,-bstatic -wl,-bdynamic -wl,--end-group -g ...failed gcc.link bin/gcc-4.7.0/debug/node... ...failed updating 1 target... ...updated 1 target... it seems bjam correctly find header, not libs. tried tell bjam find boost :
jamfile :
use-project /boost : /usr/lib/boost ; exe node : main.cpp /boost//system ; but bjam produce :
/usr/share/boost-build/build/project.jam:270: in find-jamfile module project error: unable load jamfile. error: not find jamfile in directory '/usr/lib/boost'. error: attempted find pattern '[bb]uild.jam [jj]amfile.v2 [jj]amfile [jj]amfile.jam'. error: please consult documentation @ 'http://www.boost.org'. /usr/share/boost-build/build/project.jam:290: in load-jamfile module project /usr/share/boost-build/build/project.jam:68: in project.load module project /usr/share/boost-build/build/project.jam:718: in project.use module project /usr/share/boost-build/build/project.jam:94: in load-used-projects module project /usr/share/boost-build/build/project.jam:79: in load module project /usr/share/boost-build/build/project.jam:170: in project.find module project /usr/share/boost-build/build-system.jam:248: in load module build-system /usr/share/boost-build/kernel/modules.jam:261: in import module modules /usr/share/boost-build/kernel/bootstrap.jam:132: in boost-build module /usr/share/boost-build/boost-build.jam:1: in module scope module it unerstand bjam want rebuild boost, that's why it's looking jamfile in /usr/lib/boost.
is there missing ? how tell bjam missing libs link against ?
some times ago, used
linklibs = -lboost_system -lboost_filesystem ; but don't know how translate boost.build v2.
thanks.
finally, got solution. expected <linkflags> able take more 1 lib, wrong.
here fix, changed jamfile :
exe node : main.cpp : <linkflags>-lpthread <linkflags>-lboost_system ;
Comments
Post a Comment