5
votes

I installed OpenCV to Ubuntu 14.04. I'm trying to fallow tutorials at opencv website. I got an error while running this code. I'm using eclipse to run the code. I'm getting this error while building project. I added, opencv_core, opencv_highgui,opencv_imgcodecs libraries to g++ linker.

Error message: 

//usr/local/lib/libopencv_imgproc.so.3.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [optest01] Error 1

Code :

#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include <stdlib.h>
#include <stdio.h>

using namespace cv;

/// Global variables

Mat src, src_gray;
Mat dst, detected_edges;

/** @function main */
int main( int argc, char** argv )
{
  /// Load an image
  src = imread( "/images/Lenna.jpg" );

  if( !src.data )
  { return -1; }

  /// Create a matrix of the same type and size as src (for dst)
  dst.create( src.size(), src.type() );

  /// Convert the image to grayscale
  cvtColor( src, src_gray, COLOR_BGR2GRAY );

  return 0;
  }
2
Have you linked opencv_imgproc? - Miki
@Miki, thank you for the answer it works. how can i know that which libraries to link at tutorials it is not writing - seleucia
1) add one by one according to the error message until it works 2) add them all in the first place 3) add the lib according to your #include 4) once you know how OpenCV works, you'll know what to link - Miki
@Miki You should post your comment as the answer to this question so seleucia can accept it - NoChecksum

2 Answers

13
votes

Your error code:

//usr/local/lib/libopencv_imgproc.so.3.0: error adding symbols: DSO missing from command line

is telling you that you haven't linked opencv_imgproc. Just link the required library:

-lopencv_imgproc
2
votes

I had the similar problem DSO missing from command line and adding the -L/usr/local/libin front solved the problem for me i.e. g++ source_code.cpp -o output_name -L/usr/local/lib <dependent libraries e.g. -lopencv_highgui>