Ask Your Question

compile time errors in openCV/C++ code.

asked 2015-03-27 12:50:21 -0500

namiqaliyev gravatar image

I have a openCV & c++ code like below.

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int main(int argc, const char *argv[])
    Mat res(720,502,CV_8UC3,Scalar(0,255,255));
    vector<int> sparam;
    namedWindow("Open Picture",CV_WINDOW_AUTOSIZE);
    imshow("Open Picture",res);
    destroyWindow("Open Picture");
    return 0;

When I do g++ openpic.cpp -lopencv_core -lopencv_highgui for compile, it gives an error

/usr/bin/ld: /tmp/ccYxhFYr.o: undefined reference to symbol '_ZN2cv7imwriteERKNS_6StringERKNS_11_InputArrayERKSt6vectorIiSaIiEE'
//usr/local/lib/ error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

What is the problem. I am new in OPENCV, and I get many errors in c++...

edit retag flag offensive close merge delete



if you really are using opencv3.0, you additionally need -lopencv_imgcodecs , like your error says.

berak gravatar imageberak ( 2015-03-27 12:56:16 -0500 )edit

But it does not show the picture.....

namiqaliyev gravatar imagenamiqaliyev ( 2015-03-27 13:05:34 -0500 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2015-07-21 20:09:26 -0500

zhoutianyou gravatar image

If you really are using opencv3.0 , you additionally need -lopencv_videoio -lopencv_imgcodecs -lopencv_video, like your error says;

edit flag offensive delete link more

answered 2015-03-28 02:55:51 -0500

judu29hbc gravatar image

It doesn't show it because it is going too fast so you can see it. Just put something like 10000 in wait key function

edit flag offensive delete link more


boaz001 gravatar imageboaz001 ( 2015-03-28 17:44:53 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-03-27 12:50:21 -0500

Seen: 2,462 times

Last updated: Mar 28 '15