2

The Background: I need to use OpenCV for various Image Processing projects. To get it to work on my system(32-bit Windows 7, CodeBlocks IDE, TDM-GCC 4.8.1) I downloaded the OpenCV 3.0 sources from the OpenCV website and built it using Cmake(the only significant thing I did in this step was disable ipp) and mingw compiler. I linked the include directory and libraries to the C::B environment.

The Problem: When I run the following sample code I get an error.

*

#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
using namespace cv;
using namespace std;
int main()
{
Mat img;
img = imread("lena.jpg");
imshow("Original Image", img);
waitKey();
}

*

The error log being:

||=== Build: Debug in opencv (compiler: GNU GCC Compiler) ===| obj\Debug\main.o||In function ZN2cv3Mat7releaseEv':| F:\opencvbuild\include\opencv2\core\mat.inl.hpp|655|undefined reference to__atomic_fetch_add_4'| ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 9 second(s)) ===|

How do I get the library to work? Any possible hack or directly accessible binary files solution will do.

  • did you linked it right? – user1810087 May 28 '15 at 17:03
  • possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Captain Obvlious May 28 '15 at 17:05
  • can it be, that TDM-GCC does not have __atomic_fetch_add , while mingw64 does have it ? look [here](https://github.com/Itseez/opencv/blob/master/modules/core/include/opencv2/core/cvdef.h#L191) – berak May 28 '15 at 17:06
  • 1
    @berak I'll try rebuilding the library with mingw and get back to you. My pc is a 32bit machine so I can't possibly use the mingw64. – Anuj Gautam May 29 '15 at 16:08
  • @user1810087 I think I linked it right. I just linked all of the files in lib folder to the C::B environment. – Anuj Gautam May 29 '15 at 16:09
  • ^^ yes, please try that. it's a bit bad luck for mingw users atm, support from opencv is fading, since this landscape is so splintered. – berak May 29 '15 at 16:10

0 Answers0