knz
August 9, 2021, 9:08am
1
I noticed CV_DbgAssert
on linux is NO-OPd even when I build my program in debug mode. This is because _DEBUG
is not defined in my build with GCC on linux. Who is expected to define _DEBUG
? My program links to OpenCV using CMake and CMake or OpenCVConfig.cmake
does not seem to define _DEBUG
either.
MSVC seems to define _DEBUG
I appreciate if someone can point me in the right direction.
opencv2/core/base.hpp
#if defined _DEBUG || defined CV_STATIC_ANALYSIS
# define CV_DbgAssert(expr) CV_Assert(expr)
#else
/** replaced with CV_Assert(expr) in Debug configuration */
# define CV_DbgAssert(expr)
#endif
berak
August 9, 2021, 9:21am
2
cmake should have added -D _DEBUG
to the cxx compiler/linker cmdline, when building the opencv libs (it’s too late in your pogram)
can you check the cmake output, or the result from cv::getBuildInformation()
?
if it really is so, it might be a bug worth reporting
(but i have doubts, that you are right, see e.g. here, at bottom )
knz
August 9, 2021, 9:34am
3
I will check my build flags once again, thank you
knz
August 9, 2021, 9:47am
4
Yup, that is the problem. I am using the Release mode library wrongly in debug mode through CMake.
Platform:
Timestamp: 2020-09-30T09:55:12Z
Host: Linux 5.8.12-arch1-1 x86_64
CMake: 3.5.1
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
Can you help me find which CMake template defines _DEBUG
on linux? I looked through opencv/cmake/templates at master · opencv/opencv · GitHub but did not find a match
berak
August 9, 2021, 9:53am
5
CMAKE_BUILD_TYPE=DEBUG
is the resp. cmake flag.
and cmake should set the c/c++ compiler flags
maybe use a seperate build/install folder, else you overwrite your release libs !