簡體   English   中英

使用init_from_source時的Boost.Log鏈接器錯誤

[英]Boost.Log linker error when using init_from_source

我正在Windows上編寫一個使用Boost庫進行記錄的程序。 但是,當我想使用函數init_from_source初始化記錄器時,出現以下錯誤:

libboost_log_setup-vc141-mt-gd-x64-1_69.lib(matches_relation_factory.obj) : error LNK2019: unresolved external symbol "private: class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > > & __cdecl boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::do_assign(char const *,char const *,unsigned int)" (?do_assign@?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@AEAAAEAV12@PEBD0I@Z) referenced in function "public: class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > > & __cdecl boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::assign(char const *,char const *,unsigned int)" (?assign@?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@QEAAAEAV12@PEBD0I@Z)
libboost_log_setup-vc141-mt-gd-x64-1_69.lib(matches_relation_factory.obj) : error LNK2019: unresolved external symbol "public: bool __cdecl boost::re_detail_106900::perl_matcher<char const *,class std::allocator<struct boost::sub_match<char const *> >,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::match(void)" (?match@?$perl_matcher@PEBDV?$allocator@U?$sub_match@PEBD@boost@@@std@@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail_106900@boost@@QEAA_NXZ) referenced in function "bool __cdecl boost::regex_match<char const *,class std::allocator<struct boost::sub_match<char const *> >,char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >(char const *,char const *,class boost::match_results<char const *,class std::allocator<struct boost::sub_match<char const *> > > &,class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > > const &,enum boost::regex_constants::_match_flags)" (??$regex_match@PEBDV?$allocator@U?$sub_match@PEBD@boost@@@std@@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@YA_NPEBD0AEAV?$match_results@PEBDV?$allocator@U?$sub_match@PEBD@boost@@@std@@@0@AEBV?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@0@W4_match_flags@regex_constants@0@@Z)
libboost_log_setup-vc141-mt-gd-x64-1_69.lib(matches_relation_factory.obj) : error LNK2019: unresolved external symbol "private: void __cdecl boost::re_detail_106900::perl_matcher<char const *,class std::allocator<struct boost::sub_match<char const *> >,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::construct_init(class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > > const &,enum boost::regex_constants::_match_flags)" (?construct_init@?$perl_matcher@PEBDV?$allocator@U?$sub_match@PEBD@boost@@@std@@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail_106900@boost@@AEAAXAEBV?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@3@W4_match_flags@regex_constants@3@@Z) referenced in function "public: __cdecl boost::re_detail_106900::perl_matcher<char const *,class std::allocator<struct boost::sub_match<char const *> >,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::perl_matcher<char const *,class std::allocator<struct boost::sub_match<char const *> >,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >(char const *,char const *,class boost::match_results<char const *,class std::allocator<struct boost::sub_match<char const *> > > &,class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > > const &,enum boost::regex_constants::_match_flags,char const *)" (??0?$perl_matcher@PEBDV?$allocator@U?$sub_match@PEBD@boost@@@std@@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail_106900@boost@@QEAA@PEBD0AEAV?$match_results@PEBDV?$allocator@U?$sub_match@PEBD@boost@@@std@@@2@AEBV?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@2@W4_match_flags@regex_constants@2@0@Z)
libboost_log_setup-vc141-mt-gd-x64-1_69.lib(matches_relation_factory.obj) : error LNK2019: unresolved external symbol "private: class boost::basic_regex<wchar_t,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > > & __cdecl boost::basic_regex<wchar_t,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > >::do_assign(wchar_t const *,wchar_t const *,unsigned int)" (?do_assign@?$basic_regex@_WU?$regex_traits@_WV?$w32_regex_traits@_W@boost@@@boost@@@boost@@AEAAAEAV12@PEB_W0I@Z) referenced in function "public: class boost::basic_regex<wchar_t,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > > & __cdecl boost::basic_regex<wchar_t,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > >::assign(wchar_t const *,wchar_t const *,unsigned int)" (?assign@?$basic_regex@_WU?$regex_traits@_WV?$w32_regex_traits@_W@boost@@@boost@@@boost@@QEAAAEAV12@PEB_W0I@Z)
libboost_log_setup-vc141-mt-gd-x64-1_69.lib(matches_relation_factory.obj) : error LNK2019: unresolved external symbol "public: bool __cdecl boost::re_detail_106900::perl_matcher<wchar_t const *,class std::allocator<struct boost::sub_match<wchar_t const *> >,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > >::match(void)" (?match@?$perl_matcher@PEB_WV?$allocator@U?$sub_match@PEB_W@boost@@@std@@U?$regex_traits@_WV?$w32_regex_traits@_W@boost@@@boost@@@re_detail_106900@boost@@QEAA_NXZ) referenced in function "bool __cdecl boost::regex_match<wchar_t const *,class std::allocator<struct boost::sub_match<wchar_t const *> >,wchar_t,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > >(wchar_t const *,wchar_t const *,class boost::match_results<wchar_t const *,class std::allocator<struct boost::sub_match<wchar_t const *> > > &,class boost::basic_regex<wchar_t,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > > const &,enum boost::regex_constants::_match_flags)" (??$regex_match@PEB_WV?$allocator@U?$sub_match@PEB_W@boost@@@std@@_WU?$regex_traits@_WV?$w32_regex_traits@_W@boost@@@boost@@@boost@@YA_NPEB_W0AEAV?$match_results@PEB_WV?$allocator@U?$sub_match@PEB_W@boost@@@std@@@0@AEBV?$basic_regex@_WU?$regex_traits@_WV?$w32_regex_traits@_W@boost@@@boost@@@0@W4_match_flags@regex_constants@0@@Z)
libboost_log_setup-vc141-mt-gd-x64-1_69.lib(matches_relation_factory.obj) : error LNK2019: unresolved external symbol "private: void __cdecl boost::re_detail_106900::perl_matcher<wchar_t const *,class std::allocator<struct boost::sub_match<wchar_t const *> >,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > >::construct_init(class boost::basic_regex<wchar_t,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > > const &,enum boost::regex_constants::_match_flags)" (?construct_init@?$perl_matcher@PEB_WV?$allocator@U?$sub_match@PEB_W@boost@@@std@@U?$regex_traits@_WV?$w32_regex_traits@_W@boost@@@boost@@@re_detail_106900@boost@@AEAAXAEBV?$basic_regex@_WU?$regex_traits@_WV?$w32_regex_traits@_W@boost@@@boost@@@3@W4_match_flags@regex_constants@3@@Z) referenced in function "public: __cdecl boost::re_detail_106900::perl_matcher<wchar_t const *,class std::allocator<struct boost::sub_match<wchar_t const *> >,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > >::perl_matcher<wchar_t const *,class std::allocator<struct boost::sub_match<wchar_t const *> >,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > >(wchar_t const *,wchar_t const *,class boost::match_results<wchar_t const *,class std::allocator<struct boost::sub_match<wchar_t const *> > > &,class boost::basic_regex<wchar_t,struct boost::regex_traits<wchar_t,class boost::w32_regex_traits<wchar_t> > > const &,enum boost::regex_constants::_match_flags,wchar_t const *)" (??0?$perl_matcher@PEB_WV?$allocator@U?$sub_match@PEB_W@boost@@@std@@U?$regex_traits@_WV?$w32_regex_traits@_W@boost@@@boost@@@re_detail_106900@boost@@QEAA@PEB_W0AEAV?$match_results@PEB_WV?$allocator@U?$sub_match@PEB_W@boost@@@std@@@2@AEBV?$basic_regex@_WU?$regex_traits@_WV?$w32_regex_traits@_W@boost@@@boost@@@2@W4_match_flags@regex_constants@2@0@Z)
fatal error LNK1120: 6 unresolved externals


我正在像這樣構建Boost:

b2 -j8 toolset=msvc-14.1 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=complete stage
b2 -j8 toolset=msvc-14.1 address-model=64 architecture=x86 link=shared threading=multi runtime-link=shared --with-thread --build-type=minimal stage


我可以看到init_from_source已構建:

compile-c-c++ bin.v2\libs\log\build\msvc-14.1\debug\address-model-64\threadapi-win32\threading-multi\setup\init_from_stream.obj
init_from_stream.cpp

compile-c-c++ bin.v2\libs\log\build\msvc-14.1\release\address-model-64\threadapi-win32\threading-multi\setup\init_from_stream.obj
init_from_stream.cpp

我在Visual Studio中將其鏈接。


如果刪除函數init_from_stream,則代碼編譯不會有任何問題。 另外,我使用Boost來讀取配置文件和內存映射,並且效果很好。


由於它不適用於我的項目,因此我嘗試進行另一項測試。 我創建了一個新項目,將Boost鏈接到該項目,並嘗試運行以下代碼:

#include <fstream>
#include <boost/log/utility/setup/from_stream.hpp>


int main() {
    std::fstream fs{ "settings.ini" };
    boost::log::init_from_stream(fs);

    return 0;
}

再次,出現相同的問題。


如果我嘗試動態地構建它,這是我得到的錯誤:

Source.obj : error LNK2019: unresolved external symbol "void __cdecl boost::log::v2_mt_nt6::init_from_stream<char>(class std::basic_istream<char,struct std::char_traits<char> > &)" (??$init_from_stream@D@v2_mt_nt6@log@boost@@YAXAEAV?$basic_istream@DU?$char_traits@D@std@@@std@@@Z) referenced in function main


有人知道我想念什么嗎?


UPDATE

當我嘗試動態鏈接庫時,在包含之前我使用#define BOOST_LOG_DYN_LINK


我也嘗試了這些鏈接的解決方案,但沒有幫助:

Boost-log鏈接器錯誤

致命錯誤LNK1104:無法打開文件'libboost_log-vc141-mt-gd-1_64.lib'


UPDATE

boost_1_69_0 / stage / lib目錄中同時存在libboost_regex-vc141-mt-gd-x64-1_69.liblibboost_log-vc141-mt-x64-1_69.lib

缺少的符號來自Boost.Regex,Boost.Log使用它(更准確地說, boost_log_setup在內部引用其符號)。 您需要將Boost.Regex添加到要鏈接的庫列表中。 給定您的錯誤消息,對於您的靜態鏈接構建,應該為libboost_regex-vc141-mt-gd-x64-1_69.lib

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM