Qt+Opencv配置

在Win7(32)位下:

1、版本:

    Qt版本:qt-opensource-windows-x86-android-5.5.1.exe

    链接地址:http://download.qt.io/archive/qt/5.5/5.5.1/

    OpenCV版本:OpenCV2.4.1

2、安装好Qt之后,将D:\Program Files\opencv\build\x86\vc10\bin,D:\qt\5.5\mingw492_32\bin的路径添加到Path中,在创建工程的时候,向工程     .pro文件中添加:

  INCLUDEPATH+="D:/Program Files/opencv/build/include" \

                "D:/Program Files/opencv/build/include/opencv" \
                 "D:/Program Files/opencv/build/include/opencv2"
   LIBS+= -L"D:/Program Files/opencv/build/x86/vc10/lib/" -lopencv_ml2411d -lopencv_calib3d2411d -lopencv_contrib2411d -lopencv_core2411d \
          -lopencv_features2d2411d -lopencv_flann2411d -lopencv_gpu2411d -lopencv_imgproc2411d -lopencv_legacy2411d -lopencv_objdetect2411d \
          -lopencv_ts2411d -lopencv_video2411d -lopencv_nonfree2411d -lopencv_ocl2411d -lopencv_photo2411d -lopencv_stitching2411d \
          -lopencv_superres2411d -lopencv_videostab2411d -lopencv_highgui2411d

  表达式的第一部分(-L...):使链接器知道应该在哪个目录中查找库文件。双引号只在路径包含空格时才需要。

  表达式的第二部分(-l...):告诉链接器链接哪些库,没有必要指定 .lib 扩展名。

3、main.cpp如下:
      #include<opencv2/highgui/highgui.hpp>
      #include<opencv2/imgproc/imgproc.hpp>
      using namespace cv;
      int main()
      {
 
        IplImage *src = cvLoadImage("Example1.png", -1);
        cvShowImage("src", src);
        cvWaitKey(0);
        cvReleaseImage(&src);
       return 0;
     }
   并把Example1.png图片拷贝到Debug目录下,可以正常打开图片,但是将main.cpp函数改成以下:
    #include<opencv2/highgui/highgui.hpp>
    #include<opencv2/imgproc/imgproc.hpp>
    using namespace cv;
    int main()
    {
      /* IplImage *src = cvLoadImage("Example1.png", -1);
        cvShowImage("src", src);
        cvWaitKey(0);
        cvReleaseImage(&src);*/
        Mat src = imread("Example1.png", 0);
        imshow("src", src);
        waitKey(0);
        return 0;
    }
   编译出现错误:    

debug/main.o: In function `main':

C:\Users\Administrator.AZU9F7UB7BS30XB\Desktop\test\build-55y-Desktop_Qt_5_5_1_MinGW_32bit-Debug/../55y/main.cpp:11: undefined reference to `cv::imread(std::string const&, int)'

C:\Users\Administrator.AZU9F7UB7BS30XB\Desktop\test\build-55y-Desktop_Qt_5_5_1_MinGW_32bit-Debug/../55y/main.cpp:12: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'

C:\Users\Administrator.AZU9F7UB7BS30XB\Desktop\test\build-55y-Desktop_Qt_5_5_1_MinGW_32bit-Debug/../55y/main.cpp:12: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'

C:\Users\Administrator.AZU9F7UB7BS30XB\Desktop\test\build-55y-Desktop_Qt_5_5_1_MinGW_32bit-Debug/../55y/main.cpp:13: undefined reference to `cv::waitKey(int)'

debug/main.o: In function `ZN2cv3MatD1Ev':

D:/Program Files/opencv/build/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'

debug/main.o: In function `ZN2cv3Mat7releaseEv':

D:/Program Files/opencv/build/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'

collect2.exe: error: ld returned 1 exit status

Makefile.Debug:77: recipe for target 'debug\55y.exe' failed

mingw32-make[1]: *** [debug\55y.exe] Error 1

mingw32-make[1]: Leaving directory 'C:/Users/Administrator.AZU9F7UB7BS30XB/Desktop/test/build-55y-Desktop_Qt_5_5_1_MinGW_32bit-Debug'

makefile:34: recipe for target 'debug' failed

mingw32-make: *** [debug] Error 2

14:42:15: 进程"D:\qt\Tools\mingw492_32\bin\mingw32-make.exe"退出,退出代码 2 。

Error while building/deploying project 55y (kit: Desktop Qt 5.5.1 MinGW 32bit)

When executing step "Make"

说明编译器找不到lib库文件,opencv2中新添加函数和结构不能用,例如:Mat结构,imread函数,VideoCapture结构等;



                
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值