Boost logo

Boost Users :

Subject: Re: [Boost-users] compile asio against static boost libs
From: Lars Viklund (zao_at_[hidden])
Date: 2012-07-16 14:43:21


On Mon, Jul 16, 2012 at 06:50:34PM +0300, Sergiy Nazarenko wrote:
> Hi all!
>
> I would like to compile my project against static libraries
>
> 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'

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.

> I've try out to mix up places libraries and object file
> c++ .. azio.o libboost_system.a libboost_thread.a -o bin/azio
> c++ .. libboost_system.a libboost_thread.a azio.o -o bin/azio
> c++ .. libboost_thread.a azio.o libboost_system.a -o bin/azio
>
> But error is still.

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_at_[hidden]

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net