Boost.Log 由于缺少 code_convert 而无法 link 使用静态库
Boost.Log failing to link with static libraries because of missing code_convert
我正在尝试 link Boost.Log 静态地进入我的程序。 Boost.Log 已使用 bjam 与其他模块成功编译。但是,当我尝试 link 我的程序时出现错误:
g++ -g -O2 -pthread -o sonar sonar-main.o sonar-config.o sonar-util.o sonar-logger.o /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_system.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_timer.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_iostreams.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_thread.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log_setup.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_filesystem.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_atomic.a -lcrypto -lssl
sonar-logger.o: In function `void boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >::aligned_write<wchar_t>(wchar_t const*, long)':
/usr/include/boost/log/utility/formatting_ostream.hpp:702: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::string&, std::locale const&)'
/usr/include/boost/log/utility/formatting_ostream.hpp:696: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::string&, std::locale const&)'
sonar-logger.o: In function `void boost::log::v2s_mt_posix::type_dispatcher::callback_base::trampoline<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::expressions::aux::stream_ref<boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> > >&>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >(void*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
/usr/include/boost/log/utility/formatting_ostream.hpp:575: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::string&, std::locale const&)'
collect2: error: ld returned 1 exit status
我用以下内容编译了 boost:
./b2 --ignore-site-config -a -j9 --with-timer --with-system --with-chrono --with-iostreams --with-log --with-thread variant=debug link=static threading=multi
到目前为止:
- 我尝试使用这篇文章 (http://www.boost.org/doc/libs/1_60_0/libs/log/doc/html/log/rationale/namespace_mangling.html) 对其进行故障排除,这篇文章讨论了它如何成为基于编译的不同命名空间。但是,当我查看 libboost_log.a 时,我可以看到名为“void boost::log::v2s_mt_posix::aux::code_convert 的函数
- 这篇文章 (https://sourceforge.net/p/boost-log/discussion/710022/thread/2a7b5c0d/) 说要确保 BOOST_LOG_USE_CHAR 和 BOOST_LOG_USE_WCHAR_T 都没有定义。他们不是。
- 其他文章说要定义BOOST_LOG_DYN_LINK,但我用的是静态库
这是我的 Makefile.am 中的定义:
sonar_CPPFLAGS = -march=native -pipe -funroll-loops -fomit-frame-pointer -fforce-addr -fprefetch-loop-arrays -Wall -std=c++0x
sonar_SOURCES = main.cpp \
config.cpp \
config.hpp \
util.cpp \
util.hpp \
logger.cpp \
logger.hpp
sonar_LDADD = /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_system.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_timer.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_iostreams.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_thread.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log_setup.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_filesystem.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_atomic.a -lcrypto -lssl
sonar_LDFLAGS = -pthread
如何解决这个 link 错误?
您可能包括 headers 来自旧版本的 Boost。
在 1.60 中,code_convert
系列函数是模板化的,但您看到的错误是对 non-templated 函数的未定义引用。
我正在尝试 link Boost.Log 静态地进入我的程序。 Boost.Log 已使用 bjam 与其他模块成功编译。但是,当我尝试 link 我的程序时出现错误:
g++ -g -O2 -pthread -o sonar sonar-main.o sonar-config.o sonar-util.o sonar-logger.o /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_system.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_timer.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_iostreams.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_thread.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log_setup.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_filesystem.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_atomic.a -lcrypto -lssl
sonar-logger.o: In function `void boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >::aligned_write<wchar_t>(wchar_t const*, long)':
/usr/include/boost/log/utility/formatting_ostream.hpp:702: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::string&, std::locale const&)'
/usr/include/boost/log/utility/formatting_ostream.hpp:696: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::string&, std::locale const&)'
sonar-logger.o: In function `void boost::log::v2s_mt_posix::type_dispatcher::callback_base::trampoline<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::expressions::aux::stream_ref<boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> > >&>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >(void*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
/usr/include/boost/log/utility/formatting_ostream.hpp:575: undefined reference to `boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::string&, std::locale const&)'
collect2: error: ld returned 1 exit status
我用以下内容编译了 boost:
./b2 --ignore-site-config -a -j9 --with-timer --with-system --with-chrono --with-iostreams --with-log --with-thread variant=debug link=static threading=multi
到目前为止:
- 我尝试使用这篇文章 (http://www.boost.org/doc/libs/1_60_0/libs/log/doc/html/log/rationale/namespace_mangling.html) 对其进行故障排除,这篇文章讨论了它如何成为基于编译的不同命名空间。但是,当我查看 libboost_log.a 时,我可以看到名为“void boost::log::v2s_mt_posix::aux::code_convert 的函数
- 这篇文章 (https://sourceforge.net/p/boost-log/discussion/710022/thread/2a7b5c0d/) 说要确保 BOOST_LOG_USE_CHAR 和 BOOST_LOG_USE_WCHAR_T 都没有定义。他们不是。
- 其他文章说要定义BOOST_LOG_DYN_LINK,但我用的是静态库
这是我的 Makefile.am 中的定义:
sonar_CPPFLAGS = -march=native -pipe -funroll-loops -fomit-frame-pointer -fforce-addr -fprefetch-loop-arrays -Wall -std=c++0x
sonar_SOURCES = main.cpp \
config.cpp \
config.hpp \
util.cpp \
util.hpp \
logger.cpp \
logger.hpp
sonar_LDADD = /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_system.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_timer.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_iostreams.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_thread.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log_setup.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_log.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_filesystem.a /home/mike/dev/cpp/boost_1_60_0/stage/lib/libboost_atomic.a -lcrypto -lssl
sonar_LDFLAGS = -pthread
如何解决这个 link 错误?
您可能包括 headers 来自旧版本的 Boost。
在 1.60 中,code_convert
系列函数是模板化的,但您看到的错误是对 non-templated 函数的未定义引用。