Bre*_*nig 5 boost visual-c++ visual-studio-2022
我已经编译了 boost 并正在处理我的 Visual Studio 2022 项目。在 PC 升级并且操作系统更改为 Windows 11 后,我尝试重新构建 boost 并将其用于同一项目。现在我收到链接器错误,似乎我已经尝试了在线发布的所有建议修复。不知何故,似乎没有找到 lib 文件,即使我已经确认 include 和 lib 目录已正确包含,并尝试使用许多不同的配置重建 boost。
例如,boost 构建会生成 libboost_*.lib 文件
libboost_log_setup-vc143-mt-gd-x32-1_78.lib
libboost_log_setup-vc143-mt-x32-1_78.lib
libboost_log-vc143-mt-gd-x32-1_78.lib
libboost_log-vc143-mt-x32-1_78.lib
这是我的增强构建选项
x86
b2 -j 16 --stagedir=stage/Win32 线程=多 --toolset=msvc-14.3 链接=静态运行时链接=共享 --build-type=完整架构=x86 地址模型=32
x64
b2 -j 16 --stagedir=stage/x64 线程=多 --toolset=msvc-14.3 链接=静态运行时链接=共享 --build-type=完整架构=x64 --address-model=64
和我的 Visual Studio 属性
C/C++->常规->其他包含目录
C:\Program Files\Code Libraries\boost\boost_1_78_0
链接器->常规->其他库目录
C:\Program Files\Code Libraries\boost\boost_1_78_0\stage$(平台)\lib
这是错误的示例
1>Logging.obj : error LNK2019: unresolved external symbol "private: static unsigned int __cdecl boost::log::v2s_mt_nt62::attribute_name::get_id_from_string(char const *)" (?get_id_from_string@attribute_name@v2s_mt_nt62@log@boost@@CAIPBD@Z) referenced in function "public: __thiscall boost::log::v2s_mt_nt62::attribute_name::attribute_name(char const *)" (??0attribute_name@v2s_mt_nt62@log@boost@@QAE@PBD@Z)
1>Logging.obj : error LNK2001: unresolved external symbol "public: static void __cdecl boost::log::v2s_mt_nt62::aux::stream_provider<char>::release_compound(struct boost::log::v2s_mt_nt62::aux::stream_provider<char>::stream_compound *)" (?release_compound@?$stream_provider@D@aux@v2s_mt_nt62@log@boost@@SAXPAUstream_compound@12345@@Z)
1>Logging.obj : error LNK2019: unresolved external symbol "public: static void * __cdecl boost::log::v2s_mt_nt62::attribute::impl::operator new(unsigned int)" (??2impl@attribute@v2s_mt_nt62@log@boost@@SAPAXI@Z) referenced in function "class boost::log::v2s_mt_nt62::attribute_value __cdecl boost::log::v2s_mt_nt62::attributes::make_attribute_value<unsigned int &>(unsigned int &)" (??$make_attribute_value@AAI@attributes@v2s_mt_nt62@log@boost@@YA?AVattribute_value@123@AAI@Z)
1>Logging.obj : error LNK2019: unresolved external symbol "public: static void __cdecl boost::log::v2s_mt_nt62::attribute::impl::operator delete(void *,unsigned int)" (??3impl@attribute@v2s_mt_nt62@log@boost@@SAXPAXI@Z) referenced in function __unwindfunclet$??$make_attribute_value@AAI@attributes@v2s_mt_nt62@log@boost@@YA?AVattribute_value@123@AAI@Z$0
Run Code Online (Sandbox Code Playgroud)
编辑:我还想提及 Debug/Win32 的预处理器变量
WIN32_DEBUG_CONSOLE WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0A00
我无法找到 Windows 11 的 _WIN32_WINNT 值,我想这可能就是问题所在。但我不完全确定这很重要。
问题是 Boost,特别是 Boost.Log,是为不同的 Windows 版本构建的。您需要:
_WIN32_WINNT构建代码时定义的版本相同的版本。BOOST_USE_WINAPI_VERSION何时将代码构建为 Boost 应该定位的 Windows 版本,该目标版本将低于您的_WIN32_WINNT. 在构建 Boost 时还要定义_WIN32_WINNT或BOOST_USE_WINAPI_VERSION宏到该版本。要在构建 Boost 时定义宏,请添加define=macro=value到b2命令行。例如,define=_WIN32_WINNT=0x0A00。
| 归档时间: |
|
| 查看次数: |
2986 次 |
| 最近记录: |