Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opencv, DSO missing from command line collect2: error: ld returned 1 exit status

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;
  }
like image 822
seleucia Avatar asked Feb 03 '16 13:02

seleucia


2 Answers

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
like image 78
Miki Avatar answered Nov 11 '22 09:11

Miki


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>

like image 2
Ginu Jacob Avatar answered Nov 11 '22 07:11

Ginu Jacob