If you try to build OpenCV 4 or 5 Release with Visual Studio 17.10 or later with dynamic C runtime, it will die on the first attempt to use a mutex (which will be during trace initialization, or logging initialization if you have trace disabled).
The only workarounds are:
- Build it in Debug
- Build it with static runtime (/MT)
- Add the _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR preprocessor
It’s possible that this isn’t necessary if you aren’t using the Java bindings, but I promise one of these 3 is necessary if you are.
I think it would be very neighborly to add the _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR preprocessor definition when CMake detects this scenario.
I probably posted this wrong, but this knowledge came at a heavy price, and I really wish I had known earlier.