Reputation: 11
For University I need to make a few c++ projects with Opencv (version 3.1.0) in eclipse. I have linked the include and libraries of opencv like suggested in the tutorials and eclipse does indeed highlight the variables correctly.
But once I try to compile the project I get the following error(s):
g++ -L"C:\opencv\build\x64\vc14\lib" -o "DisplayImage2" ./src/DisplayImage.o -lopencv_world310 -lopencv_world310d
C:\Users\eclipse-cc-workspace\DisplayImage2\Debug/../src/DisplayImage.cpp:11: undefined reference to `cv::imread(cv::String const&, int)'
C:/opencv/build/include/opencv2/core/cvstd.hpp:625: undefined reference to `cv::String::allocate(unsigned long long)'
The same for any operator defined in opencv, not only imread.
from what I have gathered until now, these errors happen if the libraries -lopencv_imgcodecs
and similar are not linked in other versions of Opencv.
But on the 310 windows version there aren't any of these libs. The only one that there are are opencv_world310
and opencv_world310d
which I already have linked.
So I don't know why the gnu compiler doesn't find the declarations.
I tried other versions of opencv but all above 310 (which I need) only have opencv_world as their combined libraries.
Any help would be appreciated.
Upvotes: 1
Views: 90
Reputation: 231
I had the same problem with you and I have seached and tried a lot and finally had a conclusion. It seems that g++ cannot work with opencv_world310, but MSVC cl.exe can directly link opencv_world310 and works well. If you want to use g++, you should use cmake with opencv souce file first.
Upvotes: 0