Boost logo

Boost :

From: Neal D. Becker (nbecker_at_[hidden])
Date: 2003-03-28 08:09:31


I just installed boost_1_30_0 and updated to glibc-2.3.2 on my RH8.0 Linux
box. Now I have problems to create a static link of my executable.

I'm wondering what is the correct link procedure.

g++ -Wall -I ../../src/fixed -I ../../src/float -O3 -ffast-math
-fstrict-aliasing -m3dnow -ggdb -march=athlon-xp -mcpu=athlon-xp
-fprofile-arcs -D_GNU_SOURCE -Wp,-MMD,.d/Test34.d -o Test34 Test34.o -L.
-liTest -lpopt -lcephes -lfftw -static
Test34.o: In function
`boost::detail::shared_count::shared_count[in-charge]<std::basic_ofstream<char,
std::char_traits<char> >*, boost::checked_deleter<std::basic_ofstream<char,
std::char_traits<char> > > >(std::basic_ofstream<char, std::char_traits<char>
>*, boost::checked_deleter<std::basic_ofstream<char, std::char_traits<char> >
>)':
/usr/include/c++/3.2/iostream:62: undefined reference to `pthread_mutex_init'
Test34.o: In function
`boost::detail::sp_counted_base_impl<std::basic_ofstream<char,
std::char_traits<char> >*, boost::checked_deleter<std::basic_ofstream<char,
std::char_traits<char> > > >::~sp_counted_base_impl [in-charge]()':
/usr/include/c++/3.2/iostream:62: undefined reference to
`pthread_mutex_destroy'
Test34.o: In function
`boost::detail::sp_counted_base_impl<std::basic_ofstream<char,
std::char_traits<char> >*, boost::checked_deleter<std::basic_ofstream<char,
std::char_traits<char> > > >::~sp_counted_base_impl [in-charge deleting]()':
/usr/include/c++/3.2/iostream:62: undefined reference to
`pthread_mutex_destroy'
Test34.o: In function `boost::detail::sp_counted_base::~sp_counted_base
[in-charge]()':
/usr/include/c++/3.2/iostream:62: undefined reference to
`pthread_mutex_destroy'
Test34.o: In function `boost::detail::sp_counted_base::~sp_counted_base
[in-charge deleting]()':
/usr/include/c++/3.2/iostream:62: undefined reference to
`pthread_mutex_destroy'
collect2: ld returned 1 exit status

It seems adding -lpthread fixes this, but 1) I don't use thread 2) it isn't
needed for normal (nonstatic) link, and wasn't needed before the updates.

Now I see I have /usr/lib/libboost_thread.so.xxx

What is it for?

nm /usr/lib/libboost_thread.so.1.30.0
nm: /usr/lib/libboost_thread.so.1.30.0: no symbols

Is it just used to pull in -lpthread?

Apparantly, the pthread is needed because I used a boost shared pointer.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk