Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use a Release config of OpenCV with Debug config of my app?

I am writing a Universal Windows application that uses OpenCV to do camera calibration and tag detection, among other things.

I'd like to be able to use release mode, fully-optimized OpenCV DLLs while my own is in debug mode. Is this possible? If so, how do I configure CMake to make it happen?

I do want to debug my own application, naturally. However, I do not want to debug OpenCV itself. I do not want to deal with the performance drop of an OpenCV debug build, even while I'm debugging my own project. I do not want to deal with the overhead of the additional libs and dlls, and setting up my build configuration properly (this is part of a larger project, including a Unity app, so build configuration is a significant issue).

I'm using OpenCV DLLs, not static libs, so issues of differences in implementations of the STD library, etc. should not make any difference (unless OpenCV is passing those across the DLL boundary... which would be naughty indeed). Yet, when I try to build my app in Debug mode, while referencing OpenCV Release DLLs, I encounter the debug_build_guard:

error LNK2019: unresolved external symbol "bool __cdecl cv::imencode(class cv::String const &,class cv::debug_build_guard::_InputArray const &,...

It seems like what I want would be a really common use case. Unfortunately I can't seem to find anything about it anywhere. Thanks for any help!

like image 578
Evan Lang Avatar asked Oct 28 '22 23:10

Evan Lang


1 Answers

Add CV_IGNORE_DEBUG_BUILD_GUARD as one of the preprocessor definitions, which is defined in /path/to/opencv/opencv2/core/cvdef.h

like image 200
chienkan Avatar answered Nov 12 '22 23:11

chienkan