Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lucaskdc opened this issue Sep 14, 2024 · 0 comments

Comments

@lucaskdc
Copy link

lucaskdc commented Sep 14, 2024

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 lucaskdc changed the title Including boost::asio lead to link failure to boost::log due boost::winapi mismatch Including boost::asio lead to link failure to boost::log due _WIN32_WINNT mismatch Sep 14, 2024
@lucaskdc lucaskdc changed the title Including boost::asio lead to link failure to boost::log due _WIN32_WINNT mismatch Including boost::asio leads to link failure to boost::log due _WIN32_WINNT mismatch Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant