ComputationalBiomechanicsLab / opensim-creator

A UI for building OpenSim models
https://opensimcreator.com
Apache License 2.0
143 stars 17 forks source link

imgui.lib(imgui_stdlib.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in osc.obj #749

Closed iverson1github closed 1 year ago

iverson1github commented 1 year ago

I succeeded in building the project OSC in Release mode. But I failed to build the project in Debug mode. Errors as follows: imgui.lib(imgui_stdlib.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in osc.obj

adamkewley commented 1 year ago

That is a typical issue when building binaries with different debug levels with Visual Studio (specifically, MSVC). The compiler stack requires that all statically-linked code has the same debug level.

To fix this, you have to build both OpenSimCreator (the leaf project that you may be opening in Visual Studio etc.) and its dependencies (which you may be building with build_windows.bat) with the same build configuration. If you're doing this by building all dependencies using build_windows.bat (rather than, say, manually using CMake). The relevant lines to change are here:

https://github.com/ComputationalBiomechanicsLab/opensim-creator/blob/main/scripts/build_windows.bat#L11

Where permitted values are dictated by CMAKE_CONFIGURATION_TYPES when using a multi-configuration build system like visual studio:

https://cmake.org/cmake/help/latest/variable/CMAKE_CONFIGURATION_TYPES.html#variable:CMAKE_CONFIGURATION_TYPES

Note: RelWithDebInfo is a release build, but it also emits debug symbols, which is usually enough for day-to-day development - although the debugger is less effective than when using Debug (but, again, this requires having a debug build of the libraries also).

adamkewley commented 1 year ago

Also note: there's a DRAGONS comment there that says you may not be able to use Debug, because opensim-core (a separate project) has "hard-coded" some parts of its build as release-mode.

This isn't something that I can fix (it's a separate project). If you desperately want debug-level binaries you can achieve this on platforms that allow for mixed configurations, such as Mac OS or Linux (personally, I use Linux for Debug stuff) - Windows doesn't allow this.

adamkewley commented 1 year ago

Closing because I'm assuming it's fine - reopen if not.