Search code examples
c++visual-studiomsbuild

Error LNK2038 : mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in XX.obj


I'm very new to c++ and was getting this error while trying to build Release versions of my c++ OpenGL project. After some googling I went ahead and changed the Runtime Library in the C/C++ > Code Generation menu to Multi-Threaded Debug GLL (/MDd), which then fixed the issue. I'm wondering if that's the right thing to do though.

I created a new empty project as a test, and the default Runtime Library setting in Release mode is Multi-Threaded (/MD). The default Runtime Library for Debug mode is Multi-Threaded Debug (/MDd). Despite having different Runtime Libraries, both configs build successfully, which makes me wonder if there's been a mess up in my project setup at some point.

Another detail that made me curious was the output log while trying to build in Release x64:

D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\LoggerFactory.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\ConsoleAndFileLogger.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Component.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Physics.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Rotator.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\IEntitySpawnHandler.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\SpaceScene.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\ActionManager.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\DeviceManager.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Device.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Mouse.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\MouseAxis.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\MouseButton.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\InputAction.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\InputAxis.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Scene.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\GUI.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\GLFWKeyboardKeyData.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Keyboard.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\GLFWPCInputDeviceFactory.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Random.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\IndexBuffer.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Main.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Material.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Mesh.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\OpenGLUtilities.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Square.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Shader.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\ShaderManager.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\VertexArray.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\VertexBuffer.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\SceneManager.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Singleton.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\glm.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\imgui.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\imgui_demo.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\imgui_draw.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\imgui_impl_glfw_gl3.obj
**D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\x64\Release\Window.obj
**D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Camera.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Color.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Debug.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\ObjectRenderer.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Entity.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\SpaceShip.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Star.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Input.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\KeyboardKey.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Math.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Renderer.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Time.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Transform.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Vector2.obj
D:\Documents\_Projects_FAT\Gios_OpenGL\bin\intermediates\Win32\Debug\Vector3.obj

I've highlighted two lines where the intermediate file path changes from bin\x64\Release to bin\intermediates\Win32\Debug, and was wondering if this might help with the issue.


Solution

  • Though not a perfect solution, I ended up creating a new project and reimporting all dependencies one after another, compiling in between to try and find the issue. After importing all libraries, the new project just worked. I then copied all of my code and compiled it in the new solution, which worked, so the issue has been resolved.

    I saved a diff between the two project files, but couldn't find the issue (they are too different for me to make sense out of). Maybe someone with more experience can figure it out.