Reputation: 1327
Programs and versions: Windows 10, Mingw32 with gcc 6.1.0, Cmake 3.6.1, (Code::blocks 16.01)
First of all, I should mention that building a static build does work perfectly, just building a shared build does not work and I don't find workarounds for my specific problem.
I tried to build OpenCV3.1 with the abovementioned programs as shared build. Using cmake's default settings, I get following error:
[ 34%] Linking CXX executable ..\..\bin\opencv_test_core.exe
../../lib/libopencv_ts310.a(ts.cpp.obj):ts.cpp:(.text$_ZN6cvtest2TS4initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x119): undefined reference to `cv::redirectError(int (*)(int, char const*, char const*, char const*, int, void*), void*, void**)'
collect2.exe: error: ld returned 1 exit status
modules\core\CMakeFiles\opencv_test_core.dir\build.make:885: recipe for target 'bin/opencv_test_core.exe' failed
mingw32-make[2]: *** [bin/opencv_test_core.exe] Error 1
CMakeFiles\Makefile2:1713: recipe for target 'modules/core/CMakeFiles/opencv_test_core.dir/all' failed
mingw32-make[1]: *** [modules/core/CMakeFiles/opencv_test_core.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Default settings in my case means (among others): BUILD_TBB = off, BUILD_WITH_DYNAMIC_IPP = off, BUILD_opencv_world = off, ENALBE_OMIT_FRAME_POINTER = on, ENABLE_SSE/SSE2/SSE3 = on, WITH_IPP and WITH_IPP_A = off (as this seems to cause a common problem in some cases when activated).
The question now is: What does that error mean and how to fix it?
Obviously some function is missing: undefined reference to `cv::redirectError(int (*)(int, char const*, char const*, char const*, int, void*), void*, void**)
. Searching the source code gives some definitions of this function in
system.cpp
: Line 662: redirectError( CvErrorCallback errCallback, void* userdata, void** prevUserdata)
utility.hpp
: Line 174: CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, void* userdata=0, void** prevUserdata=0);
But the undefined reference wants some int an char pointers as parameters, but I don't find such a function in any source file.
When deactivating BUILD_EXAMPLES/PERF_TESTS/TESTS (as suggested somewhere else) this does not fix the problem, but gives the same problem later on:
[ 95%] Linking CXX shared library ..\..\bin\libopencv_calib3d310.dll
CMakeFiles\opencv_calib3d.dir/objects.a(calibinit.cpp.obj):calibinit.cpp:(.text$_ZN2cv15findCirclesGridERKNS_11_InputArrayENS_5Size_IiEERKNS_12_OutputArrayEiRKNS_3PtrINS_9Feature2DEEE+0x426): undefined reference to `cv::redirectError(int (*)(int, char const*, char const*, char const*, int, void*), void*, void**)'
CMakeFiles\opencv_calib3d.dir/objects.a(calibinit.cpp.obj):calibinit.cpp:(.text$_ZN2cv15findCirclesGridERKNS_11_InputArrayENS_5Size_IiEERKNS_12_OutputArrayEiRKNS_3PtrINS_9Feature2DEEE+0x44d): undefined reference to `cv::redirectError(int (*)(int, char const*, char const*, char const*, int, void*), void*, void**)'
collect2.exe: error: ld returned 1 exit status
modules\calib3d\CMakeFiles\opencv_calib3d.dir\build.make:787: recipe for target 'bin/libopencv_calib3d310.dll' failed
mingw32-make[2]: *** [bin/libopencv_calib3d310.dll] Error 1
CMakeFiles\Makefile2:3634: recipe for target 'modules/calib3d/CMakeFiles/opencv_calib3d.dir/all' failed
mingw32-make[1]: *** [modules/calib3d/CMakeFiles/opencv_calib3d.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
I havn't found any bug report or something else regarding this error.
Upvotes: 1
Views: 1099
Reputation: 11
What I did is I altered redirectError()
implementation signature in core/src/system.cpp to use ErrorCallback
instead of CvErrorCallback
for both an argument and the return value type, to match its declaration signature. Not sure why that matters though, as the both typedefs look identical; it helped nevertheless.
Upvotes: 1
Reputation: 52
Got the same problem. I've solved it with replacing cv::redirectError
with cvRedirectError
in ts.cpp as it was before this patch
Upvotes: 2