Opencv_world dll in DEBUG application

Hi,
I need to build and debug a Visual Studio C++ application that link opencv 4.x library. I do not need to debug opencv code, so I tried to use directly the release version of opencv_world dll. But, as you know, I fell into linking errors. I tried to avoid them using the preprocessor directive CV_IGNORE_DEBUG_BUILD_GUARD, but I fell into problems at runtime (e.g. imread failure).

I know that using debug version of opencv dll I will solve all those issues, but using it I cannot debug properly my application, because running time will be really affected by opencv debugging. How can I avoid these problems? There is a way to use properly release opencv in my debug configuration or could someone advice me how to build a lightweight debug opencv dll?

thank you for the attention,
best regards
Andrea

I would use a release with debug info (RelWithDebInfo) build. That is build a release version of your application and link against the release version of OpenCV but include debug symbols in your code. You can optionally remove optimization from your code as well if it doesn’t effect the runtime too heavily.

Additionaly if you want to be able to inspect the OpenCV code during debugging you could also pass the BUILD_WITH_DEBUG_INFO=ON to CMake before building OpenCV to include debug symbols in the release version of the OpenCV dll.

I would prefer a solution where my application will maintain an unchanged DEBUG configuration while linking a ‘release’ version of OpenCV. I do not need to delve into OpenCV code during debugging but I need to do that on my own code.

Is there any way to change OpenCV VC project configuration to let it produce a dll able to match my debug application without its own debug info?