win10 + Qt5.13 + OpenCV3.4.6 environment to build

win10-x64 + Qt5.13 + OpenCV3.4.6-x64 environmental structures

cmake:cmake-3.15.0-rc3-win64-x64

Preparation: mounting the Qt (plus MingGW64 bit compiler) + Installation OpenCV (64-bit) is mounted cmake-x64 +
add environmental variables:
  D: \ the Qt \ Qt5.13.0 \ 5.13.0 \ mingw73_64 \ bin
  D: \ the Qt \ QT5. 13.0 \ Tools \ mingw730_64 \ bin
  D: \ OpenCV \ Build \ x64 \ VC15 \ bin
  D: \ cmake-3.15.0-RC3-win64-x64 \ bin
  D: \ opencv3.4.6-Build \ install \ x64 \ mingw \ bin

Note: Extraction path when installing the OpenCV, (important things to say three times <I myself fell into the pit, depressed for two days>)
  file ***** opencv where the folder name must not have spaces **** * For example: "Program files"
  documents ***** opencv where the folder name must not have spaces *****
  documents ***** opencv where the folder name must not have spaces *****


1. Run cmake bin folder in the gui begin to configure
  where is the source code fill OpenCV source code path
  where to build the binaries compiled after fill the generated file storage location D: \ opencv3.4.6-build (can create your own a folder)
  Advanced check

  By clicking the Configure button will pop up configuration box
  Specify choose MinGW Makefiles the generator for this project drop-down box, then circle Specify native comilers, click on Next
  will select the C / C ++ compiler MinGW position after, fill in the corresponding compiler position (confirmed Qt compiler is usually installed in the Tools folder in the directory in Qt),
  Fortran do not fill after configuration click Finsh, configure authentication.

  Then there will be a series of red value
  check: WITH_QT, WITH_OPENGL
  problem-based compiler that appear, at one time not checked: WITH_IPP ENABLE_PRECOMPILED_HEADERS WITH_OPENCL_D3D11_NV
  then re Configure, until the red option disappears, Generate


2. Before compiling: opencv find "OpenCVCompilerOption.cmake" \ cmake \ under, open commented #add_extra_compiler_option (-Werror = non-virtual-dtor)


3. Compile: in D: \ directory under opencv3.4.6-build, shift + right to open the shell, execute instructions mingw32-make -j 8 (8 threads fast compilation)


4. Installation mingw32-make: mingw32-make install executing instructions after compilation


5.Qt configure OpenCV: Create or open a project, add the following two statements in the pro file, a header file is compiled clip, a static library, a library is a dynamic, two libraries choose to use a
  Note: LIBS + = -L must be added later '\' (or the compiler error)
  INCLUDEPATH + = D: \ Build-opencv3.4.6 \ the install \ the include

  = -L + LIBS \
  #D: \ opencv3.4.6-Build \ the install \ x64-\ MinGW \ lib \ libopencv _ * A.
  D:. \ Opencv3.4.6-Build \ the install \ x64-\ MinGW \ bin \ * _ DLL libopencv
  Engineering right on the implementation of qmake, you can compile.


6. Test Code CPP:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv2/opencv.hpp>

using namespace cv;

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    Mat srcImg = imread("D:\\_Diagonal.jpg");
    imshow("1",srcImg);
}

MainWindow::~MainWindow()
{
    delete ui;
}

  

Guess you like

Origin www.cnblogs.com/zzx1905/p/11249652.html