franzhong
franzhong
采纳率100%
2020-06-09 15:01

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

5
已采纳

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标准改变问题,造成与库不一致,这可咋整哦,晕~

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答