Cannot compile houghline.cpp after installing openCV 2.4.9 [closed]
When i compile openCV2.4.9 sample code using following command
g++ houghlines.cpp -o application `pkg-config --cflags --libs opencv`
I get following errors, any suggestions pointers to solve it ?
houghlines.cpp:6:17: error: ‘cv’ is not a namespace-name
using namespace cv;
^
houghlines.cpp:6:19: error: expected namespace-name before ‘;’ token
using namespace cv;
^
houghlines.cpp: In function ‘int main(int, char**)’:
houghlines.cpp:20:5: error: ‘Mat’ was not declared in this scope
Mat src = imread(filename, 0);
^
houghlines.cpp:20:9: error: expected ‘;’ before ‘src’
Mat src = imread(filename, 0);
^
houghlines.cpp:21:8: error: ‘src’ was not declared in this scope
if(src.empty())
^
houghlines.cpp:28:9: error: expected ‘;’ before ‘dst’
Mat dst, cdst;
^
houghlines.cpp:29:11: error: ‘src’ was not declared in this scope
Canny(src, dst, 50, 200, 3);
^
houghlines.cpp:29:16: error: ‘dst’ was not declared in this scope
Canny(src, dst, 50, 200, 3);
^
houghlines.cpp:29:31: error: ‘Canny’ was not declared in this scope
Canny(src, dst, 50, 200, 3);
^
houghlines.cpp:30:19: error: ‘cdst’ was not declared in this scope
cvtColor(dst, cdst, COLOR_GRAY2BGR);
^
houghlines.cpp:30:25: error: ‘COLOR_GRAY2BGR’ was not declared in this scope
cvtColor(dst, cdst, COLOR_GRAY2BGR);
^
houghlines.cpp:30:39: error: ‘cvtColor’ was not declared in this scope
cvtColor(dst, cdst, COLOR_GRAY2BGR);
^
houghlines.cpp:49:5: error: ‘vector’ was not declared in this scope
vector<Vec4i> lines;
^
houghlines.cpp:49:12: error: ‘Vec4i’ was not declared in this scope
vector<Vec4i> lines;
^
houghlines.cpp:49:19: error: ‘lines’ was not declared in this scope
vector<Vec4i> lines;
^
houghlines.cpp:50:32: error: ‘CV_PI’ was not declared in this scope
HoughLinesP(dst, lines, 1, CV_PI/180, 50, 50, 10 );
^
houghlines.cpp:50:54: error: ‘HoughLinesP’ was not declared in this scope
HoughLinesP(dst, lines, 1, CV_PI/180, 50, 50, 10 );
^
houghlines.cpp:53:15: error: expected ‘;’ before ‘l’
Vec4i l = lines[i];
^
houghlines.cpp:54:27: error: ‘l’ was not declared in this scope
line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
^
houghlines.cpp:54:37: error: ‘Point’ was not declared in this scope
line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
^
houghlines.cpp:54:73: error: ‘Scalar’ was not declared in this scope
line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
^
houghlines.cpp:54:79: error: ‘CV_AA’ was not declared in this scope
line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
^
houghlines.cpp:54:84: error: ‘line’ was not declared in this scope
line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
^
houghlines.cpp:57:25: error: ‘imshow’ was not declared in this scope
imshow("source", src);
^
houghlines.cpp:60:13: error: ‘waitKey’ was not declared in this scope
waitKey();
^
I am afraid there is something wrong with your configuration. Just built 2.4.9 and this houghlines sample and it builds perfectly fine. I am using the following g++ command
g++ houghlines.cpp houghlines.o pkg-config opencv --libs
thank you for reply StevenPuttemans, i am using it in virtualbox installed ubuntu ? do you think that can be a problem ?, what steps you followed to build and install OpenCV 2.4.9 ?
Just the following simple steps
Than afterwards using the pkg-config generator does all the tricks for me.
I had followed the steps you have mentioned except
pkg-config generator
, if possible any hint on that ?its just adding that config line in your optional linker settings. That is what I do in codeblocks.
Hi StevenPuttemanas, i followed the steps you mentioned and finally i could solve the issue. Before that i had used the
opencv2_4_9.sh
to install but it didn't work. Thank you for help