Hi,everyone:
This is the first time for me to write a mail in english,
so i may make some mistake,forgive me and thank you.
I'm compiling our project on linux,and my environment is:
os:fedora 12
compiler:gcc version 4.4.4
program language:c++
libraries:boost_1_46_1,log4cplus,librtmp,protobuf,libnat etc.
I compile the project in static link mode,since the protobuf
is just a static library(google recommended),and i don't down
how to complie between a shared library and a static library.
I konw boost::thread depend on pthread,so i let gcc to link
pthread with -lpthread, but i still got the follow link error, the
add-on files is all the makefile and a error report:
g++ -o letvp2sp -g -O2 -W -Wall -D_DEBUG -std=c++0x -Wl,-rpath -static
-I../include -I../P2SP -I../../log4cplus-1.0.4/include
-L../../log4cplus-1.0.4/lib -L../Debug -llog4cplus -lp2sp -ldatamgr
-lpthread -lrt -lboost_thread letvp2sp.cpp
/tmp/cc4u6ZiF.o: In function `call_once':
/opt/boost/include/boost/thread/pthread/once.hpp:51: undefined reference to
`boost::detail::get_once_per_thread_epoch()'
/tmp/cc4u6ZiF.o: In function `pthread_mutex_scoped_lock':
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:24:
undefined reference to `boost::detail::once_epoch_mutex'
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:26:
undefined reference to `boost::detail::once_epoch_mutex'
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:26:
undefined reference to `pthread_mutex_lock'
/tmp/cc4u6ZiF.o: In function `call_once':
/opt/boost/include/boost/thread/pthread/once.hpp:88: undefined reference to
`boost::detail::once_global_epoch'
/opt/boost/include/boost/thread/pthread/once.hpp:88: undefined reference to
`boost::detail::once_global_epoch'
/tmp/cc4u6ZiF.o: In function `checked_deletePLAYERS::players_service':
/opt/boost/include/boost/checked_delete.hpp:34: undefined reference to
`PLAYERS::players_service::~players_service()'
/tmp/cc4u6ZiF.o: In function `call_once':
/opt/boost/include/boost/thread/pthread/once.hpp:84: undefined reference to
`boost::detail::once_epoch_mutex'
/opt/boost/include/boost/thread/pthread/once.hpp:84: undefined reference to
`boost::detail::once_epoch_cv'
/opt/boost/include/boost/thread/pthread/once.hpp:84: undefined reference to
`pthread_cond_wait'
/tmp/cc4u6ZiF.o: In function `pthread_mutex_scoped_unlock':
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:51:
undefined reference to `boost::detail::once_epoch_mutex'
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:51:
undefined reference to `pthread_mutex_unlock'
/tmp/cc4u6ZiF.o: In function
`Utility::SingletonPLAYERS::players_service::init()':
/home/szj0306/letv_gl_p2sp/trunk/letvp2sp/../include/Singleton.h:24:
undefined reference to
`PLAYERS::players_service::players_service(std::basic_string const&)'
/tmp/cc4u6ZiF.o: In function `checked_deletePLAYERS::players_service':
/opt/boost/include/boost/checked_delete.hpp:34: undefined reference to
`PLAYERS::players_service::~players_service()'
/tmp/cc4u6ZiF.o: In function `~pthread_mutex_scoped_unlock':
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:55:
undefined reference to `boost::detail::once_epoch_mutex'
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:55:
undefined reference to `pthread_mutex_lock'
/tmp/cc4u6ZiF.o: In function `call_once':
/opt/boost/include/boost/thread/pthread/once.hpp:77: undefined reference to
`boost::detail::once_global_epoch'
/opt/boost/include/boost/thread/pthread/once.hpp:77: undefined reference to
`boost::detail::once_global_epoch'
/opt/boost/include/boost/thread/pthread/once.hpp:78: undefined reference to
`boost::detail::once_epoch_cv'
/opt/boost/include/boost/thread/pthread/once.hpp:77: undefined reference to
`boost::detail::once_global_epoch'
/opt/boost/include/boost/thread/pthread/once.hpp:77: undefined reference to
`boost::detail::once_global_epoch'
/opt/boost/include/boost/thread/pthread/once.hpp:78: undefined reference to
`pthread_cond_broadcast'
/tmp/cc4u6ZiF.o: In function `~pthread_mutex_scoped_unlock':
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:55:
undefined reference to `boost::detail::once_epoch_mutex'
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:55:
undefined reference to `pthread_mutex_lock'
/tmp/cc4u6ZiF.o: In function `call_once':
/opt/boost/include/boost/thread/pthread/once.hpp:73: undefined reference to
`boost::detail::once_epoch_cv'
/opt/boost/include/boost/thread/pthread/once.hpp:73: undefined reference to
`pthread_cond_broadcast'
/tmp/cc4u6ZiF.o: In function `checked_deletePLAYERS::players_service':
/opt/boost/include/boost/checked_delete.hpp:34: undefined reference to
`PLAYERS::players_service::~players_service()'
/tmp/cc4u6ZiF.o: In function `__static_initialization_and_destruction_0':
/opt/boost/include/boost/system/error_code.hpp:214: undefined reference to
`boost::system::generic_category()'
/opt/boost/include/boost/system/error_code.hpp:215: undefined reference to
`boost::system::generic_category()'
/opt/boost/include/boost/system/error_code.hpp:216: undefined reference to
`boost::system::system_category()'
/tmp/cc4u6ZiF.o: In function `get_system_category':
/opt/boost/include/boost/asio/error.hpp:220: undefined reference to
`boost::system::system_category()'
/tmp/cc4u6ZiF.o: In function `posix_tss_ptr_create':
/opt/boost/include/boost/asio/detail/impl/posix_tss_ptr.ipp:34: undefined
reference to `pthread_key_create'
/tmp/cc4u6ZiF.o: In function `get_system_category':
/opt/boost/include/boost/asio/error.hpp:220: undefined reference to
`boost::system::system_category()'
/tmp/cc4u6ZiF.o: In function `checked_deletePLAYERS::players_service':
/opt/boost/include/boost/checked_delete.hpp:34: undefined reference to
`PLAYERS::players_service::~players_service()'
/tmp/cc4u6ZiF.o: In function `~posix_tss_ptr':
/opt/boost/include/boost/asio/detail/posix_tss_ptr.hpp:48: undefined
reference to `pthread_key_delete'
/tmp/cc4u6ZiF.o: In function
`boost::pthread::pthread_mutex_scoped_lock::unlock()':
/opt/boost/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:30:
undefined reference to `pthread_mutex_unlock'
/tmp/cc4u6ZiF.o: In function
`Utility::SingletonPLAYERS::players_service::init()':
/home/szj0306/letv_gl_p2sp/trunk/letvp2sp/../include/Singleton.h:24:
undefined reference to
`PLAYERS::players_service::players_service(std::basic_string const&)'
/tmp/cc4u6ZiF.o: In function `checked_deletePLAYERS::players_service':
/opt/boost/include/boost/checked_delete.hpp:34: undefined reference to
`PLAYERS::players_service::~players_service()'
/usr/lib/gcc/i686-redhat-linux/4.4.4/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+0x3f): undefined
reference to `pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/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+0x77): undefined
reference to `pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/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+0x197): undefined
reference to `pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(locale_init.o): In function
`std::locale::locale()':
(.text._ZNSt6localeC2Ev+0x2b): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(locale_init.o): In function
`std::locale::locale()':
(.text._ZNSt6localeC2Ev+0x47): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(locale_init.o): In function
`std::locale::global(std::locale const&)':
(.text._ZNSt6locale6globalERKS_+0x27): undefined reference to
`pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(locale_init.o): In function
`std::locale::global(std::locale const&)':
(.text._ZNSt6locale6globalERKS_+0x8e): undefined reference to
`pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(locale_init.o): In function
`std::locale::global(std::locale const&)':
(.text._ZNSt6locale6globalERKS_+0x19a): undefined reference to
`pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(eh_alloc.o): In function
`__gnu_cxx::__scoped_lock::~__scoped_lock()':
(.text._ZN9__gnu_cxx13__scoped_lockD2Ev[_ZN9__gnu_cxx13__scoped_lockD5Ev]+0x26):
undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(eh_alloc.o): In function
`__cxa_free_exception':
(.text.__cxa_free_exception+0x69): undefined reference to
`pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(eh_alloc.o): In function
`__cxa_free_exception':
(.text.__cxa_free_exception+0x84): undefined reference to
`pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(eh_alloc.o): In function
`__cxa_free_dependent_exception':
(.text.__cxa_free_dependent_exception+0x6c): undefined reference to
`pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(eh_alloc.o): In function
`__cxa_free_dependent_exception':
(.text.__cxa_free_dependent_exception+0x87): undefined reference to
`pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(eh_alloc.o): In function
`__cxa_allocate_exception':
(.text.__cxa_allocate_exception+0xaf): undefined reference to
`pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(eh_alloc.o): In function
`__cxa_allocate_exception':
(.text.__cxa_allocate_exception+0x10f): undefined reference to
`pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(eh_alloc.o): In function
`__cxa_allocate_dependent_exception':
(.text.__cxa_allocate_dependent_exception+0x67): undefined reference to
`pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.a(eh_alloc.o): In function
`__cxa_allocate_dependent_exception':
(.text.__cxa_allocate_dependent_exception+0xb9): undefined reference to
`pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `__register_frame_info_bases':
(.text+0x61): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `__register_frame_info_bases':
(.text+0x78): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `__register_frame_info_table_bases':
(.text+0x12b): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `__register_frame_info_table_bases':
(.text+0x142): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `_Unwind_Find_FDE':
(.text+0x187c): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `_Unwind_Find_FDE':
(.text+0x18ca): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `__deregister_frame_info_bases':
(.text+0x1a72): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i686-redhat-linux/4.4.4/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `__deregister_frame_info_bases':
(.text+0x1af4): undefined reference to `pthread_mutex_unlock'
collect2: ld returned 1 exit status
make: *** [letvp2sp] Error 1
It troubled me for a few days.I'm puzzling.........