在VS2022使用vcpkg编译的log4cplus遇到以下错误:
21:08:14:646 1>player.lib(player_manager.obj) : error LNK2001: 无法解析的外部符号 "void __cdecl log4cplus::detail::macro_forced_log(class log4cplus::Logger const &,int,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,char const *,int,char const *)" (?macro_forced_log@detail@log4cplus@@YAXAEBVLogger@2@HAEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PEBDH2@Z)
21:08:14:646 1>rpc.lib(rpc_manager.obj) : error LNK2001: 无法解析的外部符号 "void __cdecl log4cplus::detail::macro_forced_log(class log4cplus::Logger const &,int,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,char const *,int,char const *)" (?macro_forced_log@detail@log4cplus@@YAXAEBVLogger@2@HAEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PEBDH2@Z)
21:08:14:646 1>util.lib(fist-config.obj) : error LNK2001: 无法解析的外部符号 "void __cdecl log4cplus::detail::macro_forced_log(class log4cplus::Logger const &,int,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,char const *,int,char const *)" (?macro_forced_log@detail@log4cplus@@YAXAEBVLogger@2@HAEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PEBDH2@Z)
原因:
vcpkg使用的默认字符集不是unicode,使用以下命令生成unicode字符集的log4cplus:
vcpkg.exe install log4cplus[unicode]:x64-windows #win32使用x86-windows