QT+OPENCV Configuration

Source: Internet
Author: User

Under the Win7 (32) Position:

1. Version:

QT Version: Qt-opensource-windows-x86-android-5.5.1.exe

Link Address: HTTP://DOWNLOAD.QT.IO/ARCHIVE/QT/5.5/5.5.1/

OpenCV version: OpenCV2.4.1

2, after installing QT, add the path of D:\Program Files\opencv\build\x86\vc10\bin,d:\qt\5.5\mingw492_32\bin to the path, in the creation of the project, to the project. Pro files are added:

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

The first part of an expression (-l ... : Causes the linker to know in which directory the library file should be located. Double quotation marks are only required if the path contains spaces.

The second part of the expression (-l ... ): tells the linker which libraries to link, and it is not necessary to specify the. lib extension. 3, main.cpp as follows:

      #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;
     }
   and copy the Example1.png picture to the debug directory, you can open the picture normally, but change the main.cpp function to the following:
    #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;
    }
   Compilation error occurred:    

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::d eallocate () '

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: Process "D:\qt\Tools\mingw492_32\bin\mingw32-make.exe" exits, exit code 2.

Error while Building/deploying project 55Y (kit:desktop Qt 5.5.1 MinGW 32bit)

When executing step ' make '

The compiler cannot find the Lib library file, the new function and structure can not be used in Opencv2, for example: Mat structure, imread function, videocapture structure, etc.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.