Need help in setting up boost library in ubuntu 9.10
I have compiled and installed my boost library in '/media/data/bin' in ubuntu 9.10. And I have setup the INCLUDE_PATH, LIBRARY_PATH env: $ echo $INCLUDE_PATH /media/data/bin/boost/include: $ echo $LIBRARY_PATH /media/data/bin/boost/lib: But when I compile the asio example, I get the following error: $ g++ blocking_tcp_echo_server.cpp blocking_tcp_echo_server.cpp:13:26: error: boost/bind.hpp: No such file or directory blocking_tcp_echo_server.cpp:14:31: error: boost/smart_ptr.hpp: No such file or directory blocking_tcp_echo_server.cpp:15:26: error: boost/asio.hpp: No such file or directory blocking_tcp_echo_server.cpp:16:28: error: boost/thread.hpp: No such file or directory blocking_tcp_echo_server.cpp:18: error: ‘boost’ has not been declared blocking_tcp_echo_server.cpp:22: error: ‘boost’ has not been declared blocking_tcp_echo_server.cpp:22: error: expected initializer before ‘<’ token blocking_tcp_echo_server.cpp:24: error: variable or field ‘session’ declared void blocking_tcp_echo_server.cpp:24: error: ‘socket_ptr’ was not declared in this sco $ g++ -I/media/data/bin/boost/include -L/media/data/bin/boost/lib blocking_tcp_echo_server.cpp /usr/bin/ld: /tmp/ccBXjXeh.o: in function server(boost::asio::io_service&, short):blocking_tcp_echo_server.cpp(.text+0x39e): error: undefined reference to 'boost::thread::~thread()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function server(boost::asio::io_service&, short):blocking_tcp_echo_server.cpp(.text+0x3c7): error: undefined reference to 'boost::thread::~thread()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function server(boost::asio::io_service&, short):blocking_tcp_echo_server.cpp(.text+0x3d8): error: undefined reference to 'boost::thread::~thread()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function __static_initialization_and_destruction_0(int, int):blocking_tcp_echo_server.cpp(.text+0x5ea): error: undefined reference to 'boost::system::get_system_category()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function __static_initialization_and_destruction_0(int, int):blocking_tcp_echo_server.cpp(.text+0x5f4): error: undefined reference to 'boost::system::get_generic_category()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function __static_initialization_and_destruction_0(int, int):blocking_tcp_echo_server.cpp(.text+0x5fe): error: undefined reference to 'boost::system::get_generic_category()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function __static_initialization_and_destruction_0(int, int):blocking_tcp_echo_server.cpp(.text+0x608): error: undefined reference to 'boost::system::get_generic_category()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function __static_initialization_and_destruction_0(int, int):blocking_tcp_echo_server.cpp(.text+0x612): error: undefined reference to 'boost::system::get_system_category()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::system::error_code::error_code():blocking_tcp_echo_server.cpp(.text._ZN5boost6system10error_codeC1Ev+0x10): error: undefined reference to 'boost::system::get_system_category()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::asio::error::get_system_category():blocking_tcp_echo_server.cpp(.text._ZN5boost4asio5error19get_system_categoryEv+0x7): error: undefined reference to 'boost::system::get_system_category()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::asio::detail::posix_thread::~posix_thread():blocking_tcp_echo_server.cpp(.text._ZN5boost4asio6detail12posix_threadD1Ev+0x1d): error: undefined reference to 'pthread_detach' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::asio::detail::posix_thread::join():blocking_tcp_echo_server.cpp(.text._ZN5boost4asio6detail12posix_thread4joinEv+0x25): error: undefined reference to 'pthread_join' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::detail::thread_data_base::thread_data_base():blocking_tcp_echo_server.cpp(.text._ZN5boost6detail16thread_data_baseC2Ev+0x1b): error: undefined reference to 'vtable for boost::detail::thread_data_base' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::thread::thread<boost::_bi::bind_t<void, void (*)(boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >), boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > >
(boost::_bi::bind_t<void, void (*)(boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >), boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > >, boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >), boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > >&, boost::detail::thread_move_t<boost::_bi::bind_t<void, void (*)(boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >), boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > > > , boost::thread::dummy*>::type):blocking_tcp_echo_server.cpp(.text._ZN5boost6threadC1INS_3_bi6bind_tIvPFvNS_10shared_ptrINS_4asio19basic_stream_socketINS5_2ip3tcpENS5_21stream_socket_serviceIS8_EEEEEEENS2_5list1INS2_5valueISC_EEEEEEEET_NS_10disable_ifINS_14is_convertibleIRSK_NS_6detail13thread_move_tISK_EEEEPNS0_5dummyEE4typeE+0x66): error: undefined reference to 'boost::thread::start_thread()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::detail::thread_data<boost::_bi::bind_t<void, void (*)(boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >), boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > > ::~thread_data():blocking_tcp_echo_server.cpp(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrINS_4asio19basic_stream_socketINS5_2ip3tcpENS5_21stream_socket_serviceIS8_EEEEEEENS2_5list1INS2_5valueISC_EEEEEEED1Ev+0x28): error: undefined reference to 'boost::detail::thread_data_base::~thread_data_base()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::detail::thread_data<boost::_bi::bind_t<void, void (*)(boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >), boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > > ::~thread_data():blocking_tcp_echo_server.cpp(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrINS_4asio19basic_stream_socketINS5_2ip3tcpENS5_21stream_socket_serviceIS8_EEEEEEENS2_5list1INS2_5valueISC_EEEEEEED1Ev+0x42): error: undefined reference to 'boost::detail::thread_data_base::~thread_data_base()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::detail::thread_data<boost::_bi::bind_t<void, void (*)(boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >), boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > > ::~thread_data():blocking_tcp_echo_server.cpp(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrINS_4asio19basic_stream_socketINS5_2ip3tcpENS5_21stream_socket_serviceIS8_EEEEEEENS2_5list1INS2_5valueISC_EEEEEEED0Ev+0x28): error: undefined reference to 'boost::detail::thread_data_base::~thread_data_base()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::detail::thread_data<boost::_bi::bind_t<void, void (*)(boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >), boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > > ::~thread_data():blocking_tcp_echo_server.cpp(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrINS_4asio19basic_stream_socketINS5_2ip3tcpENS5_21stream_socket_serviceIS8_EEEEEEENS2_5list1INS2_5valueISC_EEEEEEED0Ev+0x42): error: undefined reference to 'boost::detail::thread_data_base::~thread_data_base()' /usr/bin/ld: /tmp/ccBXjXeh.o: in function typeinfo for boost::detail::thread_data<boost::_bi::bind_t<void, void (*)(boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >), boost::_bi::list1<boost::_bi::value<boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > > > > > :blocking_tcp_echo_server.cpp(.rodata._ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrINS_4asio19basic_stream_socketINS5_2ip3tcpENS5_21stream_socket_serviceIS8_EEEEEEENS2_5list1INS2_5valueISC_EEEEEEEE+0x8): error: undefined reference to 'typeinfo for boost::detail::thread_data_base' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service<boost::asio::detail::epoll_reactor<false>
::context>::~posix_tss_ptr():blocking_tcp_echo_server.cpp(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEED2Ev+0xf): error: undefined reference to 'pthread_key_delete' /usr/bin/ld: /tmp/ccBXjXeh.o: in function boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service<boost::asio::detail::epoll_reactor<false> ::context>::posix_tss_ptr():blocking_tcp_echo_server.cpp(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceINS1_13epoll_reactorILb0EEEEEE7contextEEC2Ev+0x22): error: undefined reference to 'pthread_key_create'
collect2: ld returned 1 exit status
Thank you.
n179911 wrote:
I have compiled and installed my boost library in '/media/data/bin' in ubuntu 9.10. And I have setup the INCLUDE_PATH, LIBRARY_PATH env:
$ echo $INCLUDE_PATH /media/data/bin/boost/include: $ echo $LIBRARY_PATH /media/data/bin/boost/lib:
But when I compile the asio example, I get the following error:
$ g++ blocking_tcp_echo_server.cpp blocking_tcp_echo_server.cpp:13:26: error: boost/bind.hpp: No such
What makes you think that the INCLUDE_PATH environment variable has any effect? 'man gcc' suggests it does not.
$ g++ -I/media/data/bin/boost/include -L/media/data/bin/boost/lib blocking_tcp_echo_server.cpp /usr/bin/ld: /tmp/ccBXjXeh.o: in function server(boost::asio::io_service&, short):blocking_tcp_echo_server.cpp(.text+0x39e): error: undefined reference to 'boost::thread::~thread()'
Haven't we been here before? For example, in http://old.nabble.com/Using-boost-library-on-MacOSx-td24645759.html you ask essentially the same questions. There answer here is the same as there -- you don't link to the required libraries, and in this case, it's pretty easy to guess that the required libraries are called Boost.Thread...
__static_initialization_and_destruction_0(int, int):blocking_tcp_echo_server.cpp(.text+0x5ea): error: undefined reference to 'boost::system::get_system_category()'
... and Boost.System. And you got exactly the same error about Boost.System before. boost::asio::detail::posix_thread::~posix_thread():blocking_tcp_echo_server.cpp(.text._ZN5boost4asio6detail12posix_threadD1Ev+0x1d):
error: undefined reference to 'pthread_detach' /usr/bin/ld: /tmp/ccBXjXeh.o: in function
Add -pthread command line option. - Volodya P.S. I suggest you *do not* ask the same question at the same time both on this mailing list, and on any other web sites. This results in nothing by duplication of effort.
participants (2)
-
n179911
-
Vladimir Prus