Boost - und Software statisch linken

11/10/2007 - 22:31 von Bernhard Kornberger | Report spam
Ich verwende in meiner Software verschiedene Boost-Header:

#include <boost/regex.hpp>
#include <boost/bind.hpp>
#include <boost/scoped_ptr.hpp>

Das ganze dynamisch zu bauen funktioniert einwandfrei. Hànge ich an die
LDFLAGS aber ein -static an, dann meint der Linker:

/usr/bin/g++ -o mat main.o Surface.o Polemgr.o tools.o VoroStruct.o Build_surface.o
'-L/opt/cgal331/lib' -Wl,-R/opt/cgal331/lib/i686_Linux-2.6_g++-4.1.2 -lCGAL -lCGALcore++
-lCGALQt -lCGALimageIO -lCGALPDB -lz -lmpfr -lgmpxx -lgmp -lX11 -lboost_program_options
-lm -static -lboost_regex -lboost_program_options
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/libboost_regex.a(static_mutex.o): In
function `boost::scoped_static_mutex_lock::unlock()':
(.text+0x16): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/libboost_regex.a(static_mutex.o): In
function `boost::scoped_static_mutex_lock::lock()':
(.text+0x46): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/libboost_regex.a(static_mutex.o): In
function `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()':
(.text+0x76): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/libboost_regex.a(static_mutex.o): In
function `boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()':
(.text+0xa6): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/libboost_regex.a(static_mutex.o): In
function `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&,
bool)':
(.text+0xdd): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/libboost_regex.a(static_mutex.o): In
function `boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&,
bool)':
(.text+0x10d): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale.o): In function
`std::locale::_Impl::_M_install_cache(std::locale::facet const*, unsigned int)':
(.text._ZNSt6locale5_Impl16_M_install_cacheEPKNS_5facetEj+0x80): undefined reference to
`pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale.o): In function
`std::locale::_Impl::_M_install_cache(std::locale::facet const*, unsigned int)':
(.text._ZNSt6locale5_Impl16_M_install_cacheEPKNS_5facetEj+0xc3): undefined reference to
`pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale.o): In function
`std::locale::_Impl::_M_install_cache(std::locale::facet const*, unsigned int)':
(.text._ZNSt6locale5_Impl16_M_install_cacheEPKNS_5facetEj+0x74): undefined reference to
`pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In function
`std::locale::global(std::locale const&)':
(.text._ZNSt6locale6globalERKS_+0x88): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In function
`std::locale::global(std::locale const&)':
(.text._ZNSt6locale6globalERKS_+0xcd): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In function
`std::locale::global(std::locale const&)':
(.text._ZNSt6locale6globalERKS_+0x125): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In function
`std::locale::locale()':
(.text._ZNSt6localeC1Ev+0x6f): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In function
`std::locale::locale()':
(.text._ZNSt6localeC1Ev+0x63): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In function
`std::locale::locale()':
(.text._ZNSt6localeC2Ev+0x6f): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In function
`std::locale::locale()':
(.text._ZNSt6localeC2Ev+0x63): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(eh_alloc.o): In function
`__cxa_allocate_exception':
(.text.__cxa_allocate_exception+0xc7): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(eh_alloc.o): In function
`__cxa_allocate_exception':
(.text.__cxa_allocate_exception+0xd7): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(eh_alloc.o): In function `__cxa_free_exception':
(.text.__cxa_free_exception+0x7c): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(eh_alloc.o): In function `__cxa_free_exception':
(.text.__cxa_free_exception+0x93): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(guard.o): In function `(anonymous
namespace)::static_mutex::lock()':
(.text._ZN76_GLOBAL__N_.._.._.._.._src_libstdc___v3_libsupc___guard.cc_00000000_6A39981412static_mutex4lockEv+0x26):
undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(guard.o): In function `(anonymous
namespace)::static_mutex::unlock()':
(.text._ZN76_GLOBAL__N_.._.._.._.._src_libstdc___v3_libsupc___guard.cc_00000000_6A39981412static_mutex6unlockEv+0x26):
undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function
`__deregister_frame_info_bases':
(.text+0x100e): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function
`__deregister_frame_info_bases':
(.text+0x101e): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function
`__register_frame_info_table_bases':
(.text+0x111a): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function
`__register_frame_info_table_bases':
(.text+0x1131): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function
`__register_frame_info_bases':
(.text+0x122c): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function
`__register_frame_info_bases':
(.text+0x1243): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function
`_Unwind_Find_FDE':
(.text+0x149f): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function
`_Unwind_Find_FDE':
(.text+0x14b2): undefined reference to `pthread_mutex_lock'
collect2: ld gab 1 als Ende-Status zurück
make: *** [main] Fehler 1

Scheinbar fehlt eine Komponente von Boost, die zum statischen Linken
benötigt wird. Bloß welche?

(Ubuntu, Feisty Fawn, g++ 4.1.2, libboost 1.33.1 )

lg
Bernhard
 

Lesen sie die antworten

#1 Rainer Weikusat
12/10/2007 - 10:35 | Warnen spam
Bernhard Kornberger writes:

[...]

/usr/bin/g++ -o mat main.o Surface.o Polemgr.o tools.o VoroStruct.o
Build_surface.o '-L/opt/cgal331/lib'
-Wl,-R/opt/cgal331/lib/i686_Linux-2.6_g++-4.1.2 -lCGAL -lCGALcore++
-lCGALQt -lCGALimageIO -lCGALPDB -lz -lmpfr -lgmpxx -lgmp -lX11
-lboost_program_options -lm -static -lboost_regex
-lboost_program_options



[...]

(.text._ZNSt6localeC1Ev+0x6f): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In
function `std::locale::locale()':
(.text._ZNSt6localeC1Ev+0x63): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In
function `std::locale::locale()':
(.text._ZNSt6localeC2Ev+0x6f): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(locale_init.o): In
function `std::locale::locale()':
(.text._ZNSt6localeC2Ev+0x63): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.1.2/libstdc++.a(eh_alloc.o): In function
`__cxa_allocate_exception':



[...]

Scheinbar fehlt eine Komponente von Boost, die zum statischen Linken
benötigt wird. Bloß welche?



-lpthread?

Ähnliche fragen