boost icon indicating copy to clipboard operation
boost copied to clipboard

Including boost::asio leads to link failure to boost::log due _WIN32_WINNT mismatch

Open lucaskdc opened this issue 5 months ago • 0 comments

From version 1.84.0, the boost::winapi changed its BOOST_USE_WINAPI_VERSION default value to BOOST_WINAPI_VERSION_WIN10 (0x0A00) when _WIN32_WINNT is undefined. Check here

This makes boost::log build with a different namespace since version 1.84.0 Check here

Since winapi sets BOOST_USE_WINAPI_VERSION according to _WIN32_WINNT and asio sets _WIN32_WINNT to 0x0601 by default Check here

If asio is included before log, the application including boost::log will try to find symbols for boost::log in the wrong namespace. Therefore, the headers are misinterpreted and doesn't correspond to the build boost log. Thus, link step fails and developer may find error messages like the following: error LNK2038: mismatch detected for 'boost_log_abi': value 'v2s_mt_nt6' doesn't match value 'v2s_mt_nt62' error LNK2001: unresolved external symbol "public: static void __cdecl boost::log::v2s_mt_nt6::record_view::public_data::destroy(struct boost::log::v2s_mt_nt6::record_view::public_data const *)" (?destroy@public_data@record_view@v2s_mt_nt6@log@boost@@SAXPEBU12345@@Z)

Workaround: Set the compiler definition of _WIN32_WINNT to any >= 0x0602, like 0x0A00 (the one corresponding to Windows 10).

lucaskdc avatar Sep 14 '24 19:09 lucaskdc