C++ Windows 7 上的 OpenCV 2.4 和 MinGW 入门

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10860352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 14:33:06  来源:igfitidea点击:

Getting started with OpenCV 2.4 and MinGW on Windows 7

c++windowsopencvmingw

提问by flowfree

How do I install OpenCV 2.4 and compile my code with MinGW?

如何安装 OpenCV 2.4 并使用 MinGW 编译我的代码?

回答by flowfree

1. Installing OpenCV 2.4.3

1. 安装 OpenCV 2.4.3

First, get OpenCV 2.4.3from sourceforge.net. Its a self-file-extracting so just double click the file to start installation. Install it in a directory, say C:\.

首先,从 sourceforge.net获取OpenCV 2.4.3。它是一种自解压文件,因此只需双击该文件即可开始安装。将其安装在一个目录中,例如C:\.

OpenCV self-extracting

OpenCV 自解压

Wait until all files get extracted. It will create a new directory C:\opencvwhich contains OpenCV header files, libraries, code samples, etc.

等到所有文件都被提取出来。它将创建一个C:\opencv包含 OpenCV 头文件、库、代码示例等的新目录。

Now you need to add C:\opencv\build\x86\mingw\bindirectory to your system PATH. This directory contains OpenCV DLLs which is required for running your code.

现在您需要将C:\opencv\build\x86\mingw\bin目录添加到您的系统路径。此目录包含运行代码所需的 OpenCV DLL。

Open Control PanelSystemAdvanced system settingsAdvanced TabEnvironment variables...

打开控制面板系统高级系统设置高级选项卡环境变量...

You will see a window like shown below:

您将看到如下所示的窗口:

Add OpenCV DLL directory to system path

将 OpenCV DLL 目录添加到系统路径

On the System Variables section,
select Path(1), click Edit...(2), add C:\opencv\build\x86\mingw\bin(3) then click Ok.

在 System Variables 部分,
选择Path(1),单击Edit...(2),添加C:\opencv\build\x86\mingw\bin(3) 然后单击Ok

This will completes the OpenCV 2.4.3 installation on your computer.

这将在您的计算机上完成 OpenCV 2.4.3 的安装。



2. Installing MinGW compiler suite

2.安装MinGW编译器套件

I highly recommend you to use gcc (GNU Compiler Collection) for compiling your code. gcc is the compiler suite widely available in Linux systems and MinGW is the native port for Windows.

我强烈建议您使用 gcc(GNU Compiler Collection)来编译您的代码。gcc 是 Linux 系统中广泛可用的编译器套件,而 MinGW 是 Windows 的本机端口。

Download the MinGW installerfrom Sourceforge.net and double click to start installation. Just follow the wizard and select the directory to be installed, say C:\MinGW.

从 Sourceforge.net下载MinGW 安装程序并双击开始安装。只需按照向导并选择要安装的目录,例如C:\MinGW.

Select directory in MinGW installation

在MinGW安装中选择目录

Select "C Compiler" and "C++ Compiler" to be installed.

选择要安装的“C Compiler”和“C++ Compiler”。

Select components to be installed

选择要安装的组件

The installer will download some packages from the internet so you have to wait for a while. After the installation finished, add C:\MinGW\binto your system path using the steps described before.

安装程序会从网上下载一些软件包,所以你必须等待一段时间。安装完成后,C:\MinGW\bin使用前面描述的步骤添加到您的系统路径。

Add MinGW bin directory to system path

将 MinGW bin 目录添加到系统路径

To test if your MinGW installation is success, open a command-line box and type: gcc. If everything is ok, it will display this message:

为了测试,如果你的MinGW的安装成功,打开一个命令行框,然后输入:gcc。如果一切正常,它将显示此消息:

gcc: fatal error: no input files
compilation terminated

This completes the MinGW installation, now is the time to write your "Hello, World!" program.

这样就完成了 MinGW 的安装,现在是编写“Hello, World!”的时候了。程序。



3. Write a sample code

3. 编写示例代码

Open your text editor and type the code below and save the file to loadimg.cpp.

打开您的文本编辑器并键入以下代码并将文件保存到loadimg.cpp.

#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
  Mat im = imread(argc == 2 ? argv[1] : "lena.jpg", 1);
  if (im.empty())
  {
    cout << "Cannot open image!" << endl;
    return -1;
  }

  imshow("image", im);
  waitKey(0);

  return 0;
}

Put lena.jpgor any image you like in the same directory with the file above. Open a command-line box and compile the code above by typing:

lena.jpg您喜欢的任何图像与上述文件放在同一目录中。打开一个命令行框并通过键入以下内容来编译上面的代码:

g++ -I"C:\opencv\build\include" -L"C:\opencv\build\x86\mingw\lib" loadimg.cpp -lopencv_core243 -lopencv_highgui243 -o loadimg

If it compiles successfully, it will create an executable named loadimg.exe.

如果编译成功,它将创建一个名为loadimg.exe.

Type:

类型:

loadimg

To execute the program. Result:

执行程序。结果:

The result of your first OpenCV program

你的第一个 OpenCV 程序的结果



4. Where to go from here?

4. 从这里去哪里?

Now that your OpenCV environment is ready, what's next?

现在您的 OpenCV 环境已准备就绪,下一步是什么?

  1. Go to the samples dir → C:\opencv\samples\cpp.
  2. Read and compile some code.
  3. Write your own code.
  1. 转到示例目录 → C:\opencv\samples\cpp
  2. 阅读并编译一些代码。
  3. 编写自己的代码。

回答by EyalAr

The instructions in @bsdnoobz answer are indeed helpful, but didn't get OpenCV to work on my system.

@bsdnoobz 答案中的说明确实很有帮助,但没有让 OpenCV 在我的系统上工作。

Apparently I needed to compile the library myself in order to get it to work, and not count on the pre-built binaries (which caused my programs to crash, probably due to incompatibility with my system).

显然,我需要自己编译库才能使其工作,而不是依赖预构建的二进制文件(这导致我的程序崩溃,可能是由于与我的系统不兼容)。

I did get it to work, and wrote a comprehensive guide for compiling and installing OpenCV, and configuring Netbeans to work with it.

我确实让它工作了,并编写了一份关于编译和安装 OpenCV 以及配置 Netbeans 以使用它的综合指南

For completeness, it is also provided below.

为了完整起见,下面也提供了它。



When I first started using OpenCV, I encountered two major difficulties:

当我第一次开始使用 OpenCV 时,我遇到了两个主要的困难:

  1. Getting my programs NOT to crash immediately.
  2. Making Netbeans play nice, and especially getting timehe debugger to work.
  1. 让我的程序不会立即崩溃。
  2. 让 Netbeans 运行良好,尤其是让调试器工作的时间。

I read many tutorials and "how-to" articles, but none was really comprehensive and thorough. Eventually I succeeded in setting up the environment; and after a while of using this (great) library, I decided to write this small tutorial, which will hopefully help others.

我阅读了许多教程和“操作方法”文章,但没有一篇是真正全面和透彻的。最终我成功搭建了环境;使用这个(很棒的)库一段时间后,我决定写这个小教程,希望能帮助其他人。

The are three parts to this tutorial:

本教程分为三个部分:

  1. Compiling and installing OpenCV.
  2. Configuring Netbeans.
  3. An example program.
  1. 编译和安装 OpenCV。
  2. 配置 Netbeans。
  3. 一个示例程序。

The environment I use is: Windows 7, OpenCV 2.4.0, Netbeans 7 and MinGW 3.20 (with compiler gcc 4.6.2).

我使用的环境是:Windows 7、OpenCV 2.4.0、Netbeans 7 和 MinGW 3.20(编译器 gcc 4.6.2)。

Assumptions: You already have MinGW and Netbeans installed on your system.

假设:您的系统上已经安装了 MinGW 和 Netbeans。

Compiling and installing OpenCV

编译安装OpenCV

When downloading OpenCV, the archive actually already contains pre-built binaries (compiled libraries and DLL's) in the 'build' folder. At first, I tried using those binaries, assuming somebody had already done the job of compiling for me. That didn't work.

下载 OpenCV 时,存档实际上已经在“build”文件夹中包含了预构建的二进制文件(编译的库和 DLL)。起初,我尝试使用这些二进制文件,假设有人已经为我完成了编译工作。那没有用。

Eventually I figured I have to compile the entire library on my own system in order for it to work properly.

最终我想我必须在我自己的系统上编译整个库才能正常工作。

Luckily, the compilation process is rather easy, thanks to CMake. CMake (stands for Cross-platform Make) is a tool which generates makefiles specific to your compiler and platform. We will use CMake in order to configure our building and compilation settings, generate a 'makefile', and then compile the library.

幸运的是,由于 CMake,编译过程相当简单。CMake(代表跨平台 Make)是一种生成特定于您的编译器和平台的 makefile 的工具。我们将使用 CMake 来配置我们的构建和编译设置,生成一个“makefile”,然后编译库。

The steps are:

步骤是:

  1. Download CMakeand install it (in the installation wizard choose to add CMake to the system PATH).
  2. Download the 'release' version of OpenCV.
  3. Extract the archive to a directory of your choice. I will be using c:/opencv/.
  4. Launch CMake GUI.
    1. Browse for the source directory c:/opencv/.
    2. Choose where to build the binaries. I chose c:/opencv/release.
      CMake Configuration - 1
    3. Click 'Configure'. In the screen that opens choose the generator according to your compiler. In our case it's 'MinGW Makefiles'.
      CMake Configuration - 2
    4. Wait for everything to load, afterwards you will see this screen:
      CMake Configuration - 3
    5. Change the settings if you want, or leave the defaults. When you're done, press 'Configure' again. You should see 'Configuration done' at the log window, and the red background should disappear from all the cells.
      CMake Configuration - 4
    6. At this point CMake is ready to generate the makefile with which we will compile OpenCV with our compiler. Click 'Generate' and wait for the makefile to be generated. When the process is finished you should see 'Generating done'. From this point we will no longer need CMake.
  5. Open MinGW shell (The following steps can also be done from Windows' command prompt).
    1. Enter the directory c:/opencv/release/.
    2. Type mingw32-makeand press enter. This should start the compilation process.
      MinGW Make
      MinGW Make - Compilation
    3. When the compilation is done OpenCV's binaries are ready to be used.
    4. For convenience, we should add the directory C:/opencv/release/binto the system PATH. This will make sure our programs can find the needed DLL's to run.
  1. 下载CMake并安装它(在安装向导中选择将 CMake 添加到系统 PATH)。
  2. 下载OpenCV的“发布”版本。
  3. 将存档解压缩到您选择的目录。我将使用 c:/opencv/.
  4. 启动 CMake GUI。
    1. 浏览源目录c:/opencv/
    2. 选择在哪里构建二进制文件。我选择了c:/opencv/release
      CMake 配置 - 1
    3. 单击“配置”。在打开的屏幕中,根据您的编译器选择生成器。在我们的例子中,它是“MinGW Makefiles”。
      CMake 配置 - 2
    4. 等待所有内容加载完毕,之后您将看到此屏幕:
      CMake 配置 - 3
    5. 如果需要,可以更改设置,或保留默认值。完成后,再次按“配置”。您应该在日志窗口中看到“配置完成”,并且红色背景应该从所有单元格中消失。
      CMake 配置 - 4
    6. 此时 CMake 已准备好生成我们将使用我们的编译器编译 OpenCV 的 makefile。单击“生成”并等待生成生成文件。该过程完成后,您应该会看到“生成完成”。从这一点开始,我们将不再需要 CMake。
  5. 打开 MinGW shell(以下步骤也可以从 Windows 的命令提示符完成)。
    1. 进入目录c:/opencv/release/
    2. 键入mingw32-make并按回车键。这应该开始编译过程。
      MinGW 制造
      MinGW Make - 编译
    3. 编译完成后,OpenCV 的二进制文件就可以使用了。
    4. 为方便起见,我们应该将该目录添加C:/opencv/release/bin到系统 PATH 中。这将确保我们的程序可以找到运行所需的 DLL。

Configuring Netbeans

配置 Netbeans

Netbeans should be told where to find the header files and the compiled libraries (which were created in the previous section).

应该告诉 Netbeans 在哪里可以找到头文件和编译的库(在上一节中创建)。

The header files are needed for two reasons: for compilation and for code completion. The compiled libraries are needed for the linking stage.

需要头文件有两个原因:编译和代码完成。链接阶段需要编译的库。

Note: In order for debugging to work, the OpenCV DLL's should be available, which is why we added the directory which contains them to the system PATH (previous section, step 5.4).

注意:为了调试工作,OpenCV DLL 应该可用,这就是我们将包含它们的目录添加到系统路径的原因(上一节,步骤 5.4)。

First, you should verify that Netbeans is configured correctly to work with MinGW. Please see the screenshot below and verify your settings are correct (considering paths changes according to your own installation). Also notethat the makecommand should be from msys and notfrom Cygwin.

首先,您应该验证 Netbeans 是否正确配置为与 MinGW 一起使用。请查看下面的屏幕截图并验证您的设置是否正确(根据您自己的安装考虑路径更改)。另请注意,该make命令应来自 msys 而不是来自 Cygwin。

Netbeans MinGW Configuration

Netbeans MinGW 配置

Next, for each new project you create in Netbeans, you should define the include path (the directory which contains the header files), the libraries path and the specific libraries you intend to use. Right-click the project name in the 'projects' pane, and choose 'properties'. Add the include path (modify the path according to your own installation):

接下来,对于您在 Netbeans 中创建的每个新项目,您应该定义包含路径(包含头文件的目录)、库路径和您打算使用的特定库。在“项目”窗格中右键单击项目名称,然后选择“属性”。添加include路径(根据自己的安装修改路径):

Netbeans Project Include Path

Netbeans 项目包含路径

Add the libraries path:

添加库路径:

Netbeans Libraries Path

Netbeans 库路径

Add the specific libraries you intend to use. These libraries will be dynamically linked to your program in the linking stage. Usually you will need the corelibrary plus any other libraries according to the specific needs of your program.

添加您打算使用的特定库。这些库将在链接阶段动态链接到您的程序。通常,core根据程序的特定需求,您将需要该库以及任何其他库。

Netbeans Include Libraries

Netbeans 包括库

That's it, you are now ready to use OpenCV!

就是这样,您现在可以使用 OpenCV 了!

Summary

概括

Here are the general steps you need to complete in order to install OpenCV and use it with Netbeans:

以下是安装 OpenCV 并将其与 Netbeans 一起使用所需完成的一般步骤:

  1. Compile OpenCV with your compiler.
  2. Add the directory which contains the DLL's to your system PATH (in our case: c:/opencv/release/bin).
  3. Add the directory which contains the header files to your project's include path (in our case: c:/opencv/build/include).
  4. Add the directory which contains the compiled libraries to you project's libraries path (in our case: c:/opencv/release/lib).
  5. Add the specific libraries you need to be linked with your project (for example: libopencv_core240.dll.a).
  1. 用你的编译器编译 OpenCV。
  2. 将包含 DLL 的目录添加到您的系统路径(在我们的例子中:c:/opencv/release/bin)。
  3. 将包含头文件的目录添加到项目的包含路径(在我们的例子中:c:/opencv/build/include)。
  4. 将包含编译库的目录添加到项目的库路径(在我们的例子中:c:/opencv/release/lib)。
  5. 添加需要与项目链接的特定库(例如:libopencv_core240.dll.a)。

Example - "Hello World" with OpenCV

示例 - OpenCV 中的“Hello World”

Here is a small example program which draws the text "Hello World : )" on a GUI window. You can use it to check that your installation works correctly. After compiling and running the program, you should see the following window:

这是一个在 GUI 窗口上绘制文本“Hello World :)”的小示例程序。您可以使用它来检查您的安装是否正常工作。编译并运行程序后,您应该看到以下窗口:

OpenCV Hello World

OpenCV 你好世界

#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"

using namespace cv;

int main(int argc, char** argv) {
    //create a gui window:
    namedWindow("Output",1);

    //initialize a 120X350 matrix of black pixels:
    Mat output = Mat::zeros( 120, 350, CV_8UC3 );

    //write text on the matrix:
    putText(output,
            "Hello World :)",
            cvPoint(15,70),
            FONT_HERSHEY_PLAIN,
            3,
            cvScalar(0,255,0),
            4);

    //display the image:
    imshow("Output", output);

    //wait for the user to press any key:
    waitKey(0);

    return 0;
}

回答by Nenad Bulatovic

This isn't working for me. I spent few days following every single tutorial I found on net and finally i compiled my own binaries. Everyting is described here: OpenVC 2.4.5, eclipse CDT Juno, MinGW error 0xc0000005

这对我不起作用。我花了几天时间学习我在网上找到的每一个教程,最后我编译了我自己的二进制文件。这里描述了一切OpenVC 2.4.5,eclipse CDT Juno,MinGW error 0xc0000005

After many trials and errors I decided to follow thistutorial and to compile my own binaries as it seems that too many people are complaining that precompiled binaries are NOT working for them. Eclipse CDT Juno was already installed.

经过多次试验和错误,我决定遵循教程并编译我自己的二进制文件,因为似乎有太多人抱怨预编译的二进制文件不适合他们。Eclipse CDT Juno 已安装。

My procedure was as follows:

我的程序如下:

  1. Download and install MinGW and add to the system PATH with c:/mingw/bin
  2. Download cmake from http://www.cmake.organd install it
  3. Download OpenCV2.4.5 Windows version
  4. Install/unzip Opencv to C:\OpenCV245PC\ (README,index.rst and CMakeLists.txt are there with all subfolders)
  5. Run CMake GUI tool, then
  6. Choose C:\OpenCV245PC\ as source
  7. Choose the destination, C:\OpenCV245MinGW\x86 where to build the binaries
  8. Press Configure button, choose MinGW Makefiles as the generator. There are some red highlights in the window, choose options as you need.
  9. Press the Configure button again. Configuring is now done.
  10. Press the Generate button.
  11. Exit the program when the generating is done.
  12. Exit the Cmake program.
  13. Run the command line mode (cmd.exe) and go to the destination directory C:\OpenCV245MinGW\x86
  14. Type "mingw32-make". You will see a progress of building binaries. If the command is not found, you must make sure that the system PATH is added with c:/mingw/bin. The build continues according the chosen options to a completion.
  15. In Windows system PATH (My Computer > Right button click > Properties > Advanced > Environment Variables > Path) add the destination's bin directory, C:\OpenCV245MinGW\x86\bin
  16. RESTART COMPUTER
  17. Go to the Eclipse CDT IDE, create a C++ program using the sample OpenCV code (You can use code from top of this topic).
  18. Go to Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes, and add the source OpenCV folder "C:\OpenCV245PC\build\include"
  19. Go to Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries, and add to the Libraries (-l)ONE BY ONE (this could vary from project to project, you can add all of them if you like or some of them just the ones that you need for your project): opencv_calib3d245 opencv_contrib245 opencv_core245 opencv_features2d245 opencv_flann245 opencv_gpu245 opencv_highgui245 opencv_imgproc245 opencv_legacy245 opencv_ml245 opencv_nonfree245 opencv_objdetect245 opencv_photo245 opencv_stitching245 opencv_video245 opencv_videostab245
  20. Add the built OpenCV library folder, "C:\OpenCV245MinGW\x86\lib" to Library search path (-L).
  1. 下载并安装 MinGW 并使用 c:/mingw/bin 添加到系统 PATH
  2. http://www.cmake.org下载 cmake并安装它
  3. 下载 OpenCV2.4.5 Windows 版
  4. 将 Opencv 安装/解压缩到 C:\OpenCV245PC\(README、index.rst 和 CMakeLists.txt 与所有子文件夹都在那里)
  5. 运行 CMake GUI 工具,然后
  6. 选择 C:\OpenCV245PC\ 作为源
  7. 选择目标 C:\OpenCV245MinGW\x86 在哪里构建二进制文件
  8. 按配置按钮,选择 MinGW Makefiles 作为生成器。窗口中有一些红色突出显示,根据需要选择选项。
  9. 再次按下配置按钮。配置现已完成。
  10. 按生成按钮。
  11. 生成完成后退出程序。
  12. 退出 Cmake 程序。
  13. 运行命令行模式(cmd.exe),进入目标目录C:\OpenCV245MinGW\x86
  14. 输入“mingw32-make”。您将看到构建二进制文件的进度。如果找不到该命令,则必须确保系统PATH 中添加了c:/mingw/bin。构建继续根据所选选项完成。
  15. 在Windows系统PATH(我的电脑>右键单击>属性>高级>环境变量>路径)添加目标的bin目录,C:\OpenCV245MinGW\x86\bin
  16. 重启电脑
  17. 转到 Eclipse CDT IDE,使用示例 OpenCV 代码创建 C++ 程序(您可以使用本主题顶部的代码)。
  18. 转到 Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes,并添加源 OpenCV 文件夹“C:\OpenCV245PC\build\include”
  19. 转到 Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries,然后逐个添加到Libraries (-l) 中(这可能因项目而异,如果您喜欢或其中一些只是您的项目需要的那些):opencv_calib3d245 opencv_contrib245 opencv_core245 opencv_features2d245 opencv_flann245 opencv_gpu245 opencv_highgui245 opencv_imgproc245 opencv_imgproc245 opencv_legacy245 opencv_legacy245 opencv_legacy245 opencv_legacy245 opencv_legacy245 opencv_legacy25_video24_opencv_mlnonitch24_opencv_mlnonitch54_opencv5_mlnonitch54_opencv_mlnonitch245opencv_mlnonitch245opencv_mlnonitch245opencv_mlnonitch245opencv_mlnonitch245opencv_mlnonitch245_opencv_ml245_video4_opencv_mlnonitch54_opencv_ml2453_opencv_features2d245 opencv_features2d245 opencv_flann245 opencv_gpu245
  20. 将构建的 OpenCV 库文件夹“C:\OpenCV245MinGW\x86\lib”添加到库搜索路径 (-L)

You can use this code to test your setup:

您可以使用此代码来测试您的设置:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
{

Mat img = imread("c:/lenna.png", CV_LOAD_IMAGE_COLOR);

namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
imshow("MyWindow", img);

waitKey(0);
return 0;
}

Don't forget to put image to the C:/ (or wherever you might find suitable, just be sure that eclipse have read acess.

不要忘记将图像放入 C:/ (或任何您认为合适的地方,只需确保 eclipse 已读取访问。

回答by doenonesmith

If you installed opencv 2.4.2 then you need to change the -lopencv_core240to -lopencv_core242

如果您安装了 opencv 2.4.2,则需要将其更改-lopencv_core240-lopencv_core242

I made the same mistake.

我犯了同样的错误。

回答by aspadacio

On Windows 64bits it′s works:

在 Windows 64 位上它的工作原理:

  1. Download opencv-3.0 (beta), MinGW(command line tool);
  2. Add above respective bin folder to PATH var;
  3. Create an folder "release" (could be any name) into ;
  4. Into created folder, open prompt terminal and exec the below commands;
  5. Copy and Past this command

    cmake -G "MinGW Makefiles" -D CMAKE_CXX_COMPILER=mingw32-g++.exe -D WITH_IPP=OFF MAKE_MAKE_PROGRAM=mingw32-make.exe ..\

  6. Execute this command mingw32-make

  7. Execute this command mingw32-make install

  1. 下载opencv-3.0(测试版)MinGW(命令行工具);
  2. 将上面各自的 bin 文件夹添加到 PATH var;
  3. 创建一个文件夹“release”(可以是任何名称)到 ;
  4. 进入创建的文件夹,打开提示终端并执行以下命令;
  5. 复制并粘贴此命令

    cmake -G "MinGW Makefiles" -D CMAKE_CXX_COMPILER=mingw32-g++.exe -D WITH_IPP=OFF MAKE_MAKE_PROGRAM=mingw32-make.exe ..\

  6. 执行这个命令 mingw32-make

  7. 执行这个命令 mingw32-make install

DONE

完毕

回答by s.shpiz

I used the instructions in this step-by-step and it worked.

我逐步使用了此说明中的说明并且它起作用了。

http://nenadbulatovic.blogspot.co.il/2013/07/configuring-opencv-245-eclipse-cdt-juno.html

http://nenadbulatovic.blogspot.co.il/2013/07/configuring-opencv-245-eclipse-cdt-juno.html

回答by gyro

As pointed out by @Nenad Bulatovic one has to be careful while adding libraries(19th step). one should not add any trailing spaces while adding each library line by line. otherwise mingw goes haywire.

正如@Nenad Bulatovic 所指出的,在添加库(第 19 步)时必须小心。逐行添加每个库时不应添加任何尾随空格。否则 mingw 会失控。