boost - fixed by workaround: c++ : boost_log : how does compiler choose st or mt -
my env: solaris 5.10 gcc 4.8.2 boost 1.54
codes:
#include <boost/log/core.hpp> #include <boost/log/trivial.hpp> #include <boost/log/expressions.hpp> int main() { boost_log_trivial(fatal) << "init " << filename << std::endl; return 0; }
compiles options , issue:
-bash-3.2$ g++ x.cc -lboost_log -lsocket -lnsl -o x undefined first referenced symbol in file boost::log::v2s_st::aux::stream_provider<char>::allocate_compound(boost::log::v2s_st::record&) /var/tmp//ccpkqk2f.o boost::log::v2s_st::aux::unhandled_exception_count() /var/tmp//ccpkqk2f.o boost::log::v2s_st::record_view::public_data::destroy(boost::log::v2s_st::record_view::public_data const*) /var/tmp//ccpkqk2f.o boost::log::v2s_st::core::open_record(boost::log::v2s_st::attribute_set const&) /var/tmp//ccpkqk2f.o boost::log::v2s_st::trivial::logger::get() /var/tmp//ccpkqk2f.o boost::log::v2s_st::core::get_logging_enabled() const /var/tmp//ccpkqk2f.o boost::log::v2s_st::core::push_record_move(boost::log::v2s_st::record&) /var/tmp//ccpkqk2f.o boost::log::v2s_st::aux::stream_provider<char>::release_compound(boost::log::v2s_st::aux::stream_provider<char>::stream_compound*) /var/tmp//ccpkqk2f.o boost::log::v2s_st::sources::aux::get_severity_level() /var/tmp//ccpkqk2f.o ld: fatal: symbol referencing errors. no output written x collect2: error: ld returned 1 exit status
but
-bash-3.2$ nm -a /usr/local/lib/libboost_log.so | grep unhandled_exception_count /usr/local/lib/libboost_log.so: [2277] | 735336| 24|func |glob |0 |10 |_zn5boost3log11v2_mt_posix3aux25unhandled_exception_countev
we can see there boost::log::v2s_**mt**::aux::unhandled_exception_count, hasn't boost::log::v2s_st::aux::unhandled_exception_count
.
my question how compiler choose 1 use in sistuation?
i have read http://www.boost.org/doc/libs/1_54_0/libs/log/doc/html/log/installation/config.html. still unknown "no threading support" means. trid compile -lpthread, got same error.
update
-bash-3.2$ g++ x.cc -lsocket -lnsl -o x -pthread -lboost_log undefined first referenced symbol in file boost::log::v2s_mt_posix::core::open_record(boost::log::v2s_mt_posix::attribute_set const&) /var/tmp//cczhbwis.o icu::collator::createinstance(icu::locale const&, uerrorcode&) /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.8.2/../../../libboost_regex.so.1.57.0 boost::log::v2s_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log::v2s_mt_posix::record&) /var/tmp//cczhbwis.o boost::log::v2s_mt_posix::core::get_logging_enabled() const /var/tmp//cczhbwis.o boost::log::v2s_mt_posix::aux::unhandled_exception_count() /var/tmp//cczhbwis.o icu::locale::locale(icu::locale const&) /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.8.2/../../../libboost_regex.so.1.57.0 boost::log::v2s_mt_posix::record_view::public_data::destroy(boost::log::v2s_mt_posix::record_view::public_data const*) /var/tmp//cczhbwis.o boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&) /var/tmp//cczhbwis.o icu::locale::locale() /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.8.2/../../../libboost_regex.so.1.57.0 icu::locale::~locale() /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.8.2/../../../libboost_regex.so.1.57.0 boost::log::v2s_mt_posix::aux::stream_provider<char>::release_compound(boost::log::v2s_mt_posix::aux::stream_provider<char>::stream_compound*) /var/tmp//cczhbwis.o boost::log::v2s_mt_posix::sources::aux::get_severity_level() /var/tmp//cczhbwis.o boost::log::v2s_mt_posix::trivial::logger::get() /var/tmp//cczhbwis.o ld: fatal: symbol referencing errors. no output written x collect2: error: ld returned 1 exit status
with pthread flag, starts use "mt", asking v2s_mt_posix. our library provided v2s_mt_posix3
workaround
-bash-3.2$ g++ x.cc -lsocket -lnsl -o x -pthread /usr/local/lib/libboost_log.a /usr/local/lib/libboost_log_setup.a /usr/local/lib/libboost_thread.a /usr/local/lib/libboost_system.a -lrt -bash-3.2$ ./x [2014-12-17 02:15:55.082758] [0x10000000] [fatal] init
use dynamic link still not work, unknown why
-bash-3.2$ g++ x.cc -lsocket -lnsl -o x -pthread -lboost_log -lboost_log_setup -lboost_thread -lboost_system -lrt undefined first referenced symbol in file boost::log::v2s_mt_posix::core::open_record(boost::log::v2s_mt_posix::attribute_set const&) /var/tmp//ccegh2ws.o icu::collator::createinstance(icu::locale const&, uerrorcode&) /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.8.2/../../../libboost_regex.so.1.57.0 boost::log::v2s_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log::v2s_mt_posix::record&) /var/tmp//ccegh2ws.o boost::log::v2s_mt_posix::core::get_logging_enabled() const /var/tmp//ccegh2ws.o boost::log::v2s_mt_posix::aux::unhandled_exception_count() /var/tmp//ccegh2ws.o icu::locale::locale(icu::locale const&) /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.8.2/../../../libboost_regex.so.1.57.0 boost::log::v2s_mt_posix::record_view::public_data::destroy(boost::log::v2s_mt_posix::record_view::public_data const*) /var/tmp//ccegh2ws.o boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&) /var/tmp//ccegh2ws.o icu::locale::locale() /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.8.2/../../../libboost_regex.so.1.57.0 icu::locale::~locale() /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.8.2/../../../libboost_regex.so.1.57.0 boost::log::v2s_mt_posix::aux::stream_provider<char>::release_compound(boost::log::v2s_mt_posix::aux::stream_provider<char>::stream_compound*) /var/tmp//ccegh2ws.o boost::log::v2s_mt_posix::sources::aux::get_severity_level() /var/tmp//ccegh2ws.o boost::log::v2s_mt_posix::trivial::logger::get() /var/tmp//ccegh2ws.o ld: fatal: symbol referencing errors. no output written x collect2: error: ld returned 1 exit status
you're right, compiler choose mt or st based on -pthread
flag. far dynamic linking goes, when boost built, may have done like:
./bootstrap.sh --with-libraries=log,program_options,regex,filesystem,system,thread --prefix=/opt/csw/ ./b2 link=static define="_xopen_source=600" install
link=static
build static libraries.
for me seems affect whether or not library has v2s or v2. see: http://www.boost.org/doc/libs/1_54_0/libs/log/doc/html/log/rationale/namespace_mangling.html
Comments
Post a Comment