Build OpenCV with optimization flags and debug information

asked 2017-02-04 06:36:08 -0600

lovaj gravatar image

I'm trying to profile OpenCV using Intel VTune Amplifier. In this page, there is a list of compiler options suggested to obtain the best analysis.

As you can see, it's a mix of debug flags (e.g. -g) and optimization flags (e.g. -O2 or higher), so we can say it suggest "a release mode with debugging information".

In order to profile OpenCV with VTune, I think I have to build it with these options too. However, OpenCV is built with CMAKE, and using cmake -D CMAKE_BUILD_TYPE=Release will produce optimization flags (though I don't which ones, I suppose -O3 or similars) without debugging options and viceversa using cmake -D CMAKE_BUILD_TYPE=Debug.

In conclusion, it seems that I can't build OpenCV with both -g and -O2 flags, which are both highly recommended for profiling application using VTune. Am I right?

How can I solve this?

edit retag flag offensive close merge delete