QT4.11用minGW方式调用 OpenCV4.3问题

Opencv4.3库编译好了,cmake install 完成,在"**install**目录"下结构是这样的

D:\opencv\newbuild\install\include\opencv2\imgproc...
D:\opencv\newbuild\install\x64\mingw\lib\libopencv_world430.dll.a
D:\opencv\newbuild\install\x64\mingw\bin\libopencv_world430.dll

QT中采用**minGW**方式调用opencv //.pro

INCLUDEPATH += D:\opencv\newbuild\install\include
D:\opencv\newbuild\install\include\opencv2
LIBS += D:\opencv\newbuild\install\x64\mingw\bin\libopencv_world430.dll
#这个dll 60M大小,没有生成debug版本word430d.dll...

//main.cpp

#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>//没毛病的几个包含
using namespace cv;
。。。
    string inputName = "D:\\1.jpg";
    Mat img = imread(inputName);
    imshow("img", img);

特别注意的是,imread点击**可以跳转到定义页面**

@param filename Name of file to be loaded.
@param flags Flag that can take values of cv::ImreadModes
*/
CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );

但是运行,就提示错误

error: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'

编译后要求的参数类型有偏差了?
冒似有点眉目了,可能是GCC C++11标准改变问题,造成与库不一致,这可咋整哦,晕~

c++

1个回答

franzhong
franzhong 谢谢,已解决,是库的编译问题,cmake时选择minGW也不要用默认的方式,要选用专用方式,备注链接:https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows
大约 2 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问