Prerequisite: Opencv is already installed. Source code: //include high gui headers #include "opencv2/highgui/highgui.hpp" //we are using standard and OpenCV namespaces using namespace cv; using namespace std; int main( int argc, const char** argv ){ //create a window named theWindow namedWindow("theWindow", CV_WINDOW_AUTOSIZE); //wait user hit some key waitKey(0); //destroy window named theWindow destroyWindow("theWindow"); return 0; } Build command: g++ -o firstcv $(pkg-config --libs --cflags opencv) main.cpp if error happened. /tmp/cceyijPd.o: In function `main': main.cpp:(.text+0x3d): undefined reference to `cv::namedWindow(cv::String const&, int)' main.cpp:(.text+0x53): undefined reference to `cv::waitKey(int)' main.cpp:(.text+0x70): undefined reference to `cv::destroyWindow(cv::String const&)' /tmp/cceyijPd.o: In function `cv::String::String(char const*...
Life is easy. Why don't we make it easier?