Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

do we have to give path for OpenCV in Ubuntu 13.04.If so Tell me that also ?

This is code :

#include "opencv2/opencv.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include "list"
#include "iostream"

using namespace cv; 

using namespace std;

int main( int argc, char** argv )


   Mat image;

   image = imread( argv[1], 1 );

  if( argc != 2 || !image.data )


     std::cout<< "No image data \n";

      return -1;


  namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );

  imshow( "Display Image", image );


  return 0;


This is the command to execute it I gave:

g++ DisplayImage.cpp -o DisplayImage

This is the o/p:

/tmp/ccQFky9z.o: In function `main':

DisplayImage.cpp:(.text+0x75): undefined reference to `cv::imread(std::string const&, 

DisplayImage.cpp:(.text+0x11b): undefined reference to `cv::namedWindow(std::string const&, int)'

DisplayImage.cpp:(.text+0x14c): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'

DisplayImage.cpp:(.text+0x18c): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'

DisplayImage.cpp:(.text+0x1b4): undefined reference to `cv::waitKey(int)'
/tmp/ccQFky9z.o: In function `cv::Mat::~Mat()':

DisplayImage.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'

/tmp/ccQFky9z.o: In function `cv::Mat::operator=(cv::Mat const&)':
DisplayImage.cpp:(.text._ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0x111): undefined 

reference to `cv::Mat::copySize(cv::Mat const&)'
/tmp/ccQFky9z.o: In function `cv::Mat::release()':

DisplayImage.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x47): undefined reference to `cv::Mat::deallocate()'

collect2: error: ld returned 1 exit status
share|improve this question
There is something wrong with your code. I was able to reproduce the same result in Debian. I would ask this at Stack Overflow instead. –  Braiam Sep 23 '13 at 15:12
Agreed - possibly this is your SO Q &A: stackoverflow.com/questions/7816607/… –  fossfreedom Sep 23 '13 at 15:18
I was able to compile using the solution in the answer. –  Braiam Sep 23 '13 at 15:22
add comment

closed as off-topic by Braiam, fossfreedom Sep 23 '13 at 15:18

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – Braiam, fossfreedom
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.