Compile and run OpenCV code from the command line
For OpenCV 2.4.x
cd /path/to/opencv/samples/c/
For OpenCV 3
cd /path/to/opencv/samples/cpp/
Compile
g++ -ggdb `pkg-config --cflags --libs opencv` facedetect.cpp -o facedetect
run
./facedetect
cd /path/to/opencv/samples/c/
cd /path/to/opencv/samples/cpp/
g++ -ggdb `pkg-config --cflags --libs opencv` facedetect.cpp -o facedetect
./facedetect