compile asio against static boost libs

Hi all!
I would like to compile my project against static libraries
If I compile my project in following manner:
c++ -I/usr/local/include/boost/1.49.0/ -c -o azio.o azio.cpp
c++ -L/usr/local/lib64/boost/1.49.0/ azio.o -lboost_system -o bin/azio
It is OK. But if I use static libraries:
c++ -I/usr/local/include/boost/1.49.0/ -c -o azio.o azio.cpp
c++
-L/usr/local/lib64/boost/1.49.0/ azio.o
/usr/local/lib64/boost/1.49.0/libboost_system.a
-o bin/azio
I have got error:
azio.o: In function `boost::asio::detail::posix_tss_ptr_create(unsigned
int&)':
azio.cpp:(.text._ZN5boost4asio6detail20posix_tss_ptr_createERj[boost::asio::detail::posix_tss_ptr_create(unsigned
int&)]+0x19): undefined reference to `pthread_key_create'
azio.o: In function `boost::asio::detail::posix_thread::~posix_thread()':
........
........
boost::asio::detail::task_io_service::thread_info>::context>::operator=(boost::asio::detail::call_stack

Lars, I'm very grateful to you for a useful lesson. nm - suit me a lot in my case. Thanx a lot! :) Cheers, Sergiy

On Mon, Jul 16, 2012 at 06:50:34PM +0300, Sergiy Nazarenko wrote:
So you're not linking in whatever provides the symbol 'pthread_key_create', among others.
I used strings to know where is function pthread_key_create. I found in libboost_thread.so. Next my step was:
'strings' is a very stupid tool. It just looks for things that looks like text and dumps what it finds to the terminal. If you want _intelligent_ querying of symbols used and provided, use 'nm', or some other tool designed to give you correct information.
This is because you do not provide anything that provides the missing symbols. See your compiler man-pages for the right flag, but it's typically -pthread or -lpthread, as suggested in another mail. Note also that most linkers when linking in static libraries require you to list libraries/objects that require a symbol before libraries/objects that provide it. Your command line should most likely be: $ c++ .. azio.o libboost_thread.a libboost_system.a -lpthread -o bin/azio -- Lars Viklund | zao@acc.umu.se
participants (3)
-
Igor R
-
Lars Viklund
-
Sergiy Nazarenko