Enabling Address Sanitizer results in error LNK2038: mismatch detected for 'annotate_vector': value '0' doesn't match value '1'

Mark Hastings 36 Reputation points
2022-05-26T03:00:39.607+00:00

Never had this problem with ASAN in VS 2019, but with the current latest VS 2022 17.2.2 release I have enabled ASAN for all my C++ projects and encounter this linker error when linking in other "prebuilt" C++ libraries that were not compiled with -fsanitize=address, such as boost:

libboost_thread-vc143-mt-x64-1_79.lib(thread.obj) : error LNK2038: mismatch detected for 'annotate_vector': value '0' doesn't match value '1' in ApplicationInfo.obj
   Creating library C:\source\Windows\x64\Release\XYZ.lib and object C:\source\Windows\x64\Release\XYZ.exp
C:\source\Windows\x64\Release\XYZ.dll : fatal error LNK1319: 1 mismatches detected
Done building project "XYZ.vcxproj" -- FAILED.

Is there some new requirement that all code must be built with ASAN enabled? That would severely limit its usefulness.

Developer technologies | C++
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.