Compiling 2.4.10 with Mingw 4.8 fails in ts_func.cpp

asked 2014-11-10 13:06:21 -0600

This is my first time attempting to compile OpenCV 2.4.10 or 2.4.9 using MinGW 4.8.2 from Qt 5.3 and CMake 3.1.0 under Windows 7 Professional 64 bit.

It fails with a linker error in ts_func.cpp (reproduced in full below). I am assuming it would compile without my needing to edit any source or make files and I have made a mistake somewhere. I would appreciate it if someone who has successfully compiled 2.4.10 with MinGW to verify I am doing this correctly and offer some advice on how to get a successful compile.

Qt was installed as binaries and is able to create a working Hello World app. MinGW was added to the path.

I installed the OpenCV sources via the windows installer.

I installed CMake using the defaults.

I started CMake and selected "specify compilers". I pointed them to the MinGW bin directory with gcc.exe and g++.exe.

I selected the OpenCV source directory and a new OpenCV_bin directory for the output.

I pressed the "Configure" button and had a number of red lines appear on the CMake GUI.

I changed CMAKE_BUILD_TYPE to Release.

I pressed the "configure" button and the red lines turned to white.

I pressed the "generate" button.

I opened a cmd.exe window. I changed to the opencv_bin directory where CMake was to output. I entered >mingw32-make and compilation started.

Here is the error output:

[ 36%] Building CXX object modules/core/CMakeFiles/opencv_test_core.dir/test/tes

t_rand.cpp.obj cc1plus.exe: warning: C:/develop/opencv2410/opencv_bin/modules/core/test_precomp .hpp.gch/opencv_test_core_Debug.gch: not used because __NO_INLINE__' not define d [-Winvalid-pch] Linking CXX executable ..\..\bin\opencv_test_core.exe ../../lib/libopencv_ts2410.a(ts_func.cpp.obj):ts_func.cpp:(.text$_ZN6cvtest9rand omMatERN2cv3RNGERKSt6vectorIiSaIiEEiddb+0x206): undefined reference tocv::Mat: :Mat(cv::Mat const&, cv::Range const)' ../../lib/libopencv_ts2410.a(ts_func.cpp.obj):ts_func.cpp:(.text$_ZN6cvtest16pri ntVersionInfoEb+0x87): undefined reference to cv::getBuildInformation()' C:/Qt/Tools/mingw482_32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w 64-mingw32/bin/ld.exe: ../../lib/libopencv_ts2410.a(ts_func.cpp.obj): bad reloc address 0x87 in section.text$_ZN6cvtest16printVersionInfoEb' collect2.exe: error: ld returned 1 exit status modules\core\CMakeFiles\opencv_test_core.dir\build.make:380: recipe for target ' bin/opencv_test_core.exe' failed mingw32-make[2]: [bin/opencv_test_core.exe] Error 1 CMakeFiles\Makefile2:1121: recipe for target 'modules/core/CMakeFiles/opencv_tes t_core.dir/all' failed mingw32-make[1]: [modules/core/CMakeFiles/opencv_test_core.dir/all] Error 2 Makefile:136: recipe for target 'all' failed mingw32-make: ** [all] Error 2


edit retag flag offensive close merge delete


A workaround: In CMake turn off the following BUILD variables: BUILD_PERF_TESS BUILD_TESTS BUILD_opencv_apps

And the remaining default opencv functionality will compile with mingw4.8.2

Jon.freise gravatar imageJon.freise ( 2014-11-11 11:54:43 -0600 )edit