OpenCV 2.4.10 + eclipse LUNA + mingw 4.8.1-4 + windows 7 x64 Installation/Referencing Problem

asked 2014-10-27 09:42:47 -0500

MrSALSA gravatar image

Hello everyone!

First of all excuse my bad english.

I'm trying to get above setting to work for almost 3 days now. I tried different installation manuals, configurations and heaps of tips and tricks. But still, I can't get it to work. I will always get some eclipse g++ error like: "wrong reference", although I DID put the OpenCV and MinGW paths to the PATH variable path. I added the libraries search path, the libraries I wanted to use to the specified preferences tab for my eclipse project.

The following is what I did in more detail:

I am using a Windows 7 64 bit machine.

OpenCV 2.4.10 Installation path: C:\opencv MinGW with g++ compiler version 4.8.1-4 installation path: C:\MinGW eclipse LUNA was downloaded and decompressed to C:\eclipse (workspace in here, too)

system PATH-variable: ... C:\MinGW\bin; C:\opencv\build\x86\vc12\bin;

I started eclipse with a C++ hello world project using the MinGW gcc toolchain. After that I right clicked my new project, clicked "properties" and opened C/C++ "Settings" tab. Then I clicked the GCC G++ Compiler "Includes" section and added "C:\opencv\build\include" path to the "Include paths" tab.

After that I clicked the MinGW C++ Linker "Libraries" tab and added "C:\opencv\build\x64\vc12\lib" to the "library search path" and all libraries I knew to the "Libraries" window like this:


Then I tried the standard eclipse hello world program and verified it was working.

After that I wanted to try some tutorial-code I found here:

//////START CODE///////////////////////////////////////////////
The code is this:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
Mat img = imread("c:/lenna.png", CV_LOAD_IMAGE_COLOR);

namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
imshow("MyWindow", img);

return 0;
//////END CODE////////////////////////////////////////////////////////////////

After building this code eclipse respectively gcc showed me 7 errors:

undefined reference to `cv::imread(std::string const&, int)'
undefined reference to `cv::namedWindow(std::string const&, int)'
undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
undefined reference to `cv::waitKey(int)'
undefined reference to `cv::fastFree(void*)'
undefined reference to `cv::Mat::deallocate()'

So, as I'm quite sure it has something to do with the library settings, I still cannot figure out what.

Like I said, I found a couple of tutorials supposed to describe the setting up of an "eclipse-mingw-opencv-windows7" installation, but they all use a different version of eclipse or opencv or both, or they just give clues about unix installations. Official OpenCV-Website is down and the website doesn't supply any OpenCV version between 2.3.1 to 2.4.9. I tried OpenCv version 2.2, 2.4.9 and 2.4.10.

I ... (more)

edit retag flag offensive close merge delete



prebuild opencv libs for mingw are no more shipped for some time now. also, you cannot use the vc12libs with mingw, they are for another compiler(cl).

if you must use gcc, you will have to build the opencv libs for gcc using cmake before.

also, note, that imread was moved to the imgcodecs module, so you have to link opwncv_imgcodecs, too

berak gravatar imageberak ( 2014-10-27 14:26:25 -0500 )edit

thanks for the comment barek and sorry for the late reply. i didn't notice the comment as i was checking only for the "answers"! ;) you are right, that was the porblem. meanwhile i compiled my own libraries with cmake and got them working in eclipse. your last tipp i did not know yet...i will check that asap and might give a complete "manual" to how i got everything working. thanks a lot!

MrSALSA gravatar imageMrSALSA ( 2014-11-12 06:17:19 -0500 )edit

sorry, please strike the last remark about imread above, you are using 2.4.10, and that is only about 3.0

berak gravatar imageberak ( 2014-11-12 06:23:23 -0500 )edit