visual-c++msbuild

Why does MSVC build with different definitions in the same build task?


I'm trying to build a solution from a mono-repo (I don't believe the mono-repo structure should matter). One of the projects produces errors due to mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '1' in Error.obj Every project, including the libraries, uses the same build task in MSVC Debug.

The projects' VS configurations are being generated by cli tools.

Output

163>leveldb.lib(repair.cc.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '1' in Error.obj
163>leveldb.lib(table_builder.cc.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '1' in Error.obj
....

163>..\..\bin\five\debug\citizen-resources-client.dll : fatal error LNK1319: 34 mismatches detected

This doesn't happen for anyone else using the repo. The solution successfully builds with a fresh VM. The solution successfully builds with a fresh User. I re-installed MS VS and the required build tools. I checked all 192 projects in the solution for the definitions, and they use the same debug definition.


Solution

  • I managed to fix the errors by deleting the following files in %localappdata%\vcpkg:

    vcpkg.user.props
    vcpkg.user.targets
    

    It seems MSVS was allowing vcpkg to import custom properties with the following

      <Import Condition="Exists('C:\Scripts\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets') and '$(VCPkgLocalAppDataDisabled)' == ''" Project="C:\Scripts\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets" />