Installing OpenCV with gprof - dushyantgoyal/differ GitHub Wiki
Installation of OpenCV with Gprof
Gprof is a GNU profiler used for determining which parts of a program are taking most of the execution time. Although the installation is not very straight forward. Here are the steps to be followed.
-
Download opnCV latest version $ svn co https://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk/opencv
-
Edit the configure file and remove " -f-omit--fram-pointer " from it. This is needed as otherwise -pg and -omit_frame_pointer gcc flags interfere with each other.
-
Here we complete the openCV installation using only static libraries. Now run the configure file with the following options - $ ./configure --disable-shared --enable-static --disable-apps --without-imageio --without-carbon --without-quicktime --without-python --without-gtk --without-swig --without-v4l --prefix=$HOME/Project/opcv CXXFLAGS="-fsigned-char -pg -g"
-
Run the make and make install commands. $ make $ make install
-
Now compile the openCV application using the following Makefile. Here make a note of the following -fopenmp, -ltiff, -ljpeg, -lpng, -ljasper, -lpng12, -lz. These libraries are lined later on and on dynamically shared with the openCV installation.
APP_PREFIX=metric INCLUDE_DIR=$(HOME)/Project/opcv/include/opencv LIB_DIR=$(HOME)/Project/opcv/lib CC = $(APP_PREFIX)-gcc CPP = g++ LD= $(APP_PREFIX)-ld CXXFLAGS = -I$(INCLUDE_DIR) CXXFLAGS+= -g -pg -fsigned-char LDFLAGS = -g -pg -static -L$(LIB_DIR) -lcv -lhighgui -lcxcore -lml -lcvaux -lm -lstdc++ -lpthread -ldl -fopenmp -ltiff -ljpeg -lpng -ljasper -lpng12 -lz all: metric.o $(CPP) metric.o $(LDFLAGS) -o metric metric.o: $(CPP) $(CXXFLAGS) -c metric.cpp clean: rm -f metric metric.o
-
Now execute the application file as usual with the parameters etc.
-
Generate the Gprof profiling data $ grof executable_file > gprof.out