There is an error on the blog, the first two lines are not correctly shown on the website. We will correct this. Meanwhile try to change the first two lines to the following and try the compilation again:
#include <iostream>
#include <cstdlib>
You also need to add the other include files, which are described on the website you mentioned.
bmit@bmit-HP:~/my_project/src$ gcc -o myApp myApp.cpp
myApp.cpp:5:17: error: ‘cv’ is not a namespace-name
using namespace cv;
^
myApp.cpp:5:19: error: expected namespace-name before ‘;’ token
using namespace cv;
^
myApp.cpp: In function ‘int main(int, char**)’:
myApp.cpp:8:31: error: ‘CV_MAJOR_VERSION’ was not declared in this scope
cout << "OpenCV version: " << CV_MAJOR_VERSION << '.' << CV_MINOR_VERSION << "\n";
^
myApp.cpp:8:58: error: ‘CV_MINOR_VERSION’ was not declared in this scope
cout << "OpenCV version: " << CV_MAJOR_VERSION << '.' << CV_MINOR_VERSION << "\n";
^
myApp.cpp:15:5: error: ‘Mat’ was not declared in this scope
Mat image;
^
myApp.cpp:15:9: error: expected ‘;’ before ‘image’
Mat image;
^
myApp.cpp:16:5: error: ‘image’ was not declared in this scope
image = imread( argv[1], 1 );
^
myApp.cpp:16:32: error: ‘imread’ was not declared in this scope
image = imread( argv[1], 1 );
^
myApp.cpp:22:25: error: ‘bitwise_not’ was not declared in this scope
bitwise_not(image, image);
^
myApp.cpp:23:34: error: ‘WINDOW_AUTOSIZE’ was not declared in this scope
namedWindow("Display Image", WINDOW_AUTOSIZE );
^
myApp.cpp:23:50: error: ‘namedWindow’ was not declared in this scope
namedWindow("Display Image", WINDOW_AUTOSIZE );
^
myApp.cpp:24:34: error: ‘imshow’ was not declared in this scope
imshow("Display Image", image);
^
myApp.cpp:26:14: error: ‘waitKey’ was not declared in this scope
waitKey(0);
^
bmit@bmit-HP:~/my_project/src$ gcc -o myApp myApp.cpp
myApp.cpp: In function ‘int main(int, char**)’:
myApp.cpp:17:32: error: ‘imread’ was not declared in this scope
image = imread( argv[1], 1 );
^
myApp.cpp:24:34: error: ‘WINDOW_AUTOSIZE’ was not declared in this scope
namedWindow("Display Image", WINDOW_AUTOSIZE );
^
myApp.cpp:24:50: error: ‘namedWindow’ was not declared in this scope
namedWindow("Display Image", WINDOW_AUTOSIZE );
^
myApp.cpp:25:34: error: ‘imshow’ was not declared in this scope
imshow("Display Image", image);
^
myApp.cpp:27:14: error: ‘waitKey’ was not declared in this scope
waitKey(0);
^
bmit@bmit-HP:~/my_project/src$ gcc -o myApp myApp.cpp
myApp.cpp: In function ‘int main(int, char**)’:
myApp.cpp:17:32: error: ‘imread’ was not declared in this scope
image = imread( argv[1], 1 );
^
myApp.cpp:24:34: error: ‘WINDOW_AUTOSIZE’ was not declared in this scope
namedWindow("Display Image", WINDOW_AUTOSIZE );
^
myApp.cpp:24:50: error: ‘namedWindow’ was not declared in this scope
namedWindow("Display Image", WINDOW_AUTOSIZE );
^
myApp.cpp:25:34: error: ‘imshow’ was not declared in this scope
imshow("Display Image", image);
^
myApp.cpp:27:14: error: ‘waitKey’ was not declared in this scope
waitKey(0);
^
bmit@bmit-HP:~/my_project/src$