I am new to working with OpenCV
. I am using Eclipse CDT and have installed MinGW. When ever I build the code, I get an error - Undefined reference to "cv::" in the object file i.e. .o
created from .cpp
code file.
Compiler Information: GCC C++ compiler, where I have included 3 folder paths:
- "C:\OpenCV-3.0\opencv\build\include"
- "C:\OpenCV-3.0\opencv\build\include\opencv"
- "C:\OpenCV-3.0\opencv\build\include\opencv2"
Linker Information: MinGW C++ Linker:
- Library serach path: "C:\OpenCV-3.0\opencv\build\x86\vc12\staticlib"
Libraries are added in this fashion:
opencv_core2411d
opencv_core2411
Code:
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp" using namespace cv;
#include <stdio.h>
int main( int argc, char** argv )
{
Mat image;
image = imread("D:/Work/April/Img_proc/image.jpg", 1 );
if( argc != 2 || !image.data )
{
printf("No image data \n");
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}
Error :
**** Internal Builder is used for build ****
g++ -IC:\OpenCV-3.0\opencv\build\include -IC:\OpenCV-3.0\opencv\build\include\opencv2 -IC:\OpenCV-3.0\opencv\build\include\opencv -O0 -g3 -Wall -c -fmessage-length=0 -osrc\DisplayImage.o ..\src\DisplayImage.cpp
g++ -LC:\OpenCV-3.0\opencv\build\x86\vc12\staticlib -oOpenCV_CPP.exe src\DisplayImage.o -lopencv_core2411d -lopencv_core2411 -lopencv_imgproc2411d -lopencv_imgproc2411 -lopencv_highgui2411d -lopencv_highgui2411 -lopencv_ml2411 -lopencv_video2411 -lopencv_features2d2411 -lopencv_calib3d2411 -lopencv_objdetect2411 -lopencv_contrib2411 -lopencv_legacy2411 -lopencv_flann2411
src\DisplayImage.o: In function `main':
C:\Users\730716\workspace\OpenCV_CPP\Debug/../src/DisplayImage.cpp:14: undefined reference to `cv::imread(std::string const&, int)'
C:\Users\730716\workspace\OpenCV_CPP\Debug/../src/DisplayImage.cpp:20: undefined reference to `cv::namedWindow(std::string const&, int)'
C:\Users\730716\workspace\OpenCV_CPP\Debug/../src/DisplayImage.cpp:21: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\730716\workspace\OpenCV_CPP\Debug/../src/DisplayImage.cpp:21: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
C:\Users\730716\workspace\OpenCV_CPP\Debug/../src/DisplayImage.cpp:22: undefined reference to `cv::waitKey(int)'
src\DisplayImage.o: In function `ZN2cv3MatD1Ev':
C:/OpenCV-3.0/opencv/build/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'
src\DisplayImage.o: In function `ZN2cv3MataSERKS0_':
C:/OpenCV-3.0/opencv/build/include/opencv2/core/mat.hpp:298: undefined reference to `cv::Mat::copySize(cv::Mat const&)'
src\DisplayImage.o: In function `ZN2cv3Mat7releaseEv':
C:/OpenCV-3.0/opencv/build/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'
collect2.exe: error: ld returned 1 exit status
Build error occurred, build is stopped