程序和版本創建的OpenCV 3.1的共享版本:視窗10,MINGW32用gcc 6.1.0,3.6.1的CMake,(代碼::塊16.01)未定義參考CV :: redirectError而使用MinGW
首先,我應該提到構建靜態構建確實可行,只是構建共享構建不起作用,並且我沒有找到針對特定問題的解決方法。
我試圖用上述程序構建OpenCV3.1作爲共享構建。使用cmake的默認設置,我得到以下錯誤:
[ 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
在我的情況默認設置是指(其中包括):BUILD_TBB =關閉,BUILD_WITH_DYNAMIC_IPP =關,BUILD_opencv_world =關,ENALBE_OMIT_FRAME_POINTER =上,ENABLE_SSE/SSE2/SSE3 =在WITH_IPP和WITH_IPP_A = off(因爲這在激活時在某些情況下似乎會導致一個常見問題)。
現在的問題是:這個錯誤是什麼意思,以及如何解決它?
顯然有些功能丟失:undefined reference to `cv::redirectError(int (*)(int, char const*, char const*, char const*, int, void*), void*, void**)
。搜索源代碼給這個函數的一些定義在
system.cpp
:行662:redirectError(CvErrorCallback errCallback, void* userdata, void** prevUserdata)
utility.hpp
:行174:CV_EXPORTS ErrorCallback redirectError(ErrorCallback errCallback, void* userdata=0, void** prevUserdata=0);
但未定義的參考想要一些詮釋一個字符指針作爲參數,但我沒有在任何源文件中找到這樣的功能。
當停用BUILD_EXAMPLES/PERF_TESTS /測試(如建議在其他地方),這並不解決問題,但給以後同樣的問題:
[ 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
我沒有帶發現的缺陷報告或別的東西關於這個錯誤。
我還必須以相同的方式(兩次)更改''calibinit.cpp'',但隨後編譯沒有錯誤。謝謝! – Phann