楼主主要是想编译 opecv 库在 QT 里面使用,但是编译遇到问题,看过各种帖子还是有问题,敢请大佬指教。配置如下:
使用 QT 编译之后编译到 95%的时候链接出现问题如下:
...
[ 95%] Linking CXX shared library ..\..\bin\libopencv_world330.dll
CMakeFiles\opencv_world.dir/objects.a(parallel_pthreads.cpp.obj): In function `sscanf':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdio.h:231: undefined reference to `__mingw_vsscanf'
CMakeFiles\opencv_world.dir/objects.a(persistence.cpp.obj): In function `strtod':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdlib.h:399: undefined reference to `__mingw_strtod'
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdlib.h:399: undefined reference to `__mingw_strtod'
CMakeFiles\opencv_world.dir/objects.a(data.cpp.obj): In function `strtod':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdlib.h:399: undefined reference to `__mingw_strtod'
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdlib.h:399: undefined reference to `__mingw_strtod'
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdlib.h:399: undefined reference to `__mingw_strtod'
CMakeFiles\opencv_world.dir/objects.a(haar.cpp.obj): In function `sscanf':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdio.h:231: undefined reference to `__mingw_vsscanf'
CMakeFiles\opencv_world.dir/objects.a(THDiskFile.cpp.obj): In function `fscanf':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdio.h:253: undefined reference to `__mingw_vfscanf'
CMakeFiles\opencv_world.dir/objects.a(rgbe.cpp.obj): In function `sscanf':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdio.h:231: undefined reference to `__mingw_vsscanf'
CMakeFiles\opencv_world.dir/objects.a(cap_images.cpp.obj): In function `sscanf':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdio.h:231: undefined reference to `__mingw_vsscanf'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN11GuiReceiverC2Ev':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:798: undefined reference to `vtable for GuiReceiver'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN11GuiReceiverD2Ev':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:827: undefined reference to `vtable for GuiReceiver'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN10CvTrackbar2trEPKcS1_i':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:238: undefined reference to `CvTrackbar::staticMetaObject'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:238: undefined reference to `CvTrackbar::staticMetaObject'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN12CvPushButtonC2EP11CvButtonbar7QStringPFviPvES3_':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1480: undefined reference to `vtable for CvPushButton'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1480: undefined reference to `vtable for CvPushButton'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN10CvCheckBoxC2EP11CvButtonbar7QStringPFviPvES3_i':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1502: undefined reference to `vtable for CvCheckBox'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1502: undefined reference to `vtable for CvCheckBox'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN13CvRadioButtonC2EP11CvButtonbar7QStringPFviPvES3_i':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1525: undefined reference to `vtable for CvRadioButton'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1525: undefined reference to `vtable for CvRadioButton'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN8CvWindowD2Ev':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1687: undefined reference to `vtable for CvWindow'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1687: undefined reference to `vtable for CvWindow'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN15DefaultViewPort2trEPKcS1_i':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj):D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: more undefined references to `DefaultViewPort::staticMetaObject' follow
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN11CvButtonbarC2EP7QWidget7QString':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1424: undefined reference to `vtable for CvButtonbar'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1424: undefined reference to `vtable for CvButtonbar'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN11CvButtonbar2trEPKcS1_i':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:171: undefined reference to `CvButtonbar::staticMetaObject'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN15CvWinPropertiesC2E7QStringP7QObject':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1552: undefined reference to `vtable for CvWinProperties'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1552: undefined reference to `vtable for CvWinProperties'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN15DefaultViewPort2trEPKcS1_i':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN8CvWindow2trEPKcS1_i':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:288: undefined reference to `CvWindow::staticMetaObject'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN15DefaultViewPortC2EP8CvWindowi':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:2410: undefined reference to `vtable for DefaultViewPort'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:2410: undefined reference to `vtable for DefaultViewPort'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:2410: undefined reference to `vtable for DefaultViewPort'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN8CvWindowC2E7QStringi':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1622: undefined reference to `vtable for CvWindow'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1622: undefined reference to `vtable for CvWindow'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN15DefaultViewPortD2Ev':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:2444: undefined reference to `vtable for DefaultViewPort'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:2444: undefined reference to `vtable for DefaultViewPort'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:2444: undefined reference to `vtable for DefaultViewPort'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN10CvTrackbarC2EP8CvWindow7QStringPiiPFviPvES4_':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1295: undefined reference to `vtable for CvTrackbar'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1295: undefined reference to `vtable for CvTrackbar'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN10CvTrackbarC2EP8CvWindow7QStringPiiPFviE':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1305: undefined reference to `vtable for CvTrackbar'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1305: undefined reference to `vtable for CvTrackbar'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN15CvWinPropertiesD2Ev':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1610: undefined reference to `vtable for CvWinProperties'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.cpp:1610: undefined reference to `vtable for CvWinProperties'
CMakeFiles\opencv_world.dir/objects.a(window_QT.cpp.obj): In function `ZN15DefaultViewPort2trEPKcS1_i':
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
D:/opencv/opencv-3.3.0/opencv-3.3.0/modules/highgui/src/window_QT.h:479: undefined reference to `DefaultViewPort::staticMetaObject'
../../3rdparty/lib/liblibprotobuf.a(strtod.cc.obj): In function `strtod':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdlib.h:399: undefined reference to `__mingw_strtod'
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdlib.h:399: undefined reference to `__mingw_strtod'
../../3rdparty/lib/libzlib.a(gzlib.c.obj): In function `snprintf':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdio.h:557: undefined reference to `__ms_vsnprintf'
../../3rdparty/lib/libzlib.a(gzwrite.c.obj): In function `vsnprintf':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdio.h:545: undefined reference to `__ms_vsnprintf'
../../3rdparty/lib/liblibpng.a(pngwrite.c.obj): In function `gmtime':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/time.h:219: undefined reference to `_gmtime32'
../../3rdparty/lib/liblibjasper.a(jas_stream.c.obj): In function `vsnprintf':
D:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/stdio.h:545: undefined reference to `__ms_vsnprintf'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [bin/libopencv_world330.dll] Error 1
mingw32-make.exe[1]: *** [modules/world/CMakeFiles/opencv_world.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
modules\world\CMakeFiles\opencv_world.dir\build.make:9481: recipe for target 'bin/libopencv_world330.dll' failed
CMakeFiles\Makefile2:1349: recipe for target 'modules/world/CMakeFiles/opencv_world.dir/all' failed
Makefile:161: recipe for target 'all' failed
23:16:37: 进程"C:\Program Files\CMake\bin\cmake.exe"退出,退出代码 2。
Error while building/deploying project OpenCV (kit: Desktop Qt 5.8.0 MinGW 32bit)
When executing step "Make"
后面问题都先不管了,但是最前面的 undefined reference to '__mingw_vfscanf'
以及 undefined reference to '__ms_vsnprintf'
这类问题不知道什么原因。查了资料之后发现有类似的一个帖子说是编译工具链的问题,但是除了 cmake 其他的都是 QT 内置的啊。大佬请赐教。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.