NetBeans 7.2 MinGW为OpenCV安装 [英] NetBeans 7.2 MinGW installing for OpenCV

查看:136
本文介绍了NetBeans 7.2 MinGW为OpenCV安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我根据的2个文件





Makefile

  MKDIR_P = C:/msys/1.0/bin/mkdir -p 
DESTDIRB = build / Debug
DESTDIRD = dist / Debug
LIBDIRCV = ../build/mingw/lib
CFLAGS = -O2
CXX = C: /mingw/bin/g++.exe
Applic = imgdisplay

ALL:imgdisd

imgdisd:
$(CXX)$(CFLAGS)-c -g $(申请).cpp -I ../ build / include -MMD -MP -MF $(DESTDIRB)/ $(申请).od -o $(DESTDIRB)/ $(申请).o
$(CXX)$(CFLAGS)-o $(DESTDIRD)/ $(申请)$(DESTDIRB)/ $(申请).o -L ../ build / mingw / bin $(LIBDIRCV)/libopencv_calib3d242.dll.a $(LIBDIRCV)/libopencv_contrib242.dll.a $(LIBDIRCV)/libopencv_core242.dll.a \
$(LIBDIRCV)/libopencv_features2d242.dll.a $(LIBDIRCV)/libopencv_flann242.dll.a $(LIBDIRCV) / libop encv_gpu242.dll.a $(LIBDIRCV)/libopencv_highgui242.dll.a $(LIBDIRCV)/libopencv_imgproc242.dll.a \
$(LIBDIRCV)/libopencv_legacy242.dll.a $(LIBDIRCV)/libopencv_ml242.dll。 a $(LIBDIRCV)/libopencv_nonfree242.dll.a $(LIBDIRCV)/libopencv_objdetect242.dll.a $(LIBDIRCV)/libopencv_photo242.dll.a \
$(LIBDIRCV)/libopencv_stitching242.dll.a $(LIBDIRCV )/libopencv_ts242.a $(LIBDIRCV)/libopencv_video242.dll.a $(LIBDIRCV)/libopencv_videostab242.dll.a
md:
$(MKDIR_P)$(DESTDIRB)
$ (MKDIR_P)$(DESTDIRD)

imgdisplay.cpp

  / * 
*文件:imgdisplay.cpp
*作者:管理员
*
*创建于2012年9月14日,01:12
* /

#include< cstdlib>
#include< opencv / cv.h>
#include< opencv / highgui.h>使用namespace std

;

int main(int argc,char * argv [])
{

cvNamedWindow(mainWin,CV_WINDOW_AUTOSIZE);
cvMoveWindow(mainWin,100,100);
IplImage * img;
img = cvLoadImage(D:/grafik/Lightroom/light01.jpg);
if(!img){
std :: cout<< 无法打开图像文件<<的std :: ENDL;
返回-1;
}
cvShowImage(我的图片,img);
cvWaitKey(0);
cvReleaseImage(& img);
返回0;
}

Netbeans 7.2创建项目




  • 文件 - 新项目





使用如下所述的设置。





创建项目





创建新目标




  • 在Makefile上单击鼠标右键



注意:如果收到错误:Makefile:12:***缺少分隔符。停止。



主要是复制和粘贴错误! (确保起始行没有空格。但是设置了2个标签页。)





创建新文件夹




  • 在Makefile上单击鼠标右键

  • 使用新目标md





项目文件夹现在看起来像..





构建项目





调试项目




  • 复制所需的dll(C:\ msys \\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ CV-MakeC\dist\Debug)






  • 打开imgdisplay.cpp(双击)

  • 设置断点第17行



    17 cvNamedWindow(mainWin,CV_WINDOW_AUTOSIZE);


  • 单击调试按钮






计划在第17行停止





未解析的标识符



如果.cpp文件的来源如下所示





点击你的项目上的鼠标右键。

检查 C / C ++代码为...

运行雷帕尔se Project。





如果这还不够。

转到项目属性

如上所述填写包含输入字段。





清理




  • 如果你将sh.exe重命名为shxx.exe!重新命名它!

  • 如果你的PATH变量中有空格,请在空格周围加上引号(仅限于像visual studio这样的相关程序)。

    我知道它们不是必需的,但是一个或两个程序无法处理空格


    在路径中!!



i have installed minGW on my PC according to http://netbeans.org/community/releases/72/cpp-setup-instructions.html, and i have "restored defaults" using NetBeans 7.2 who has found all necessary files.

But when I made test sample C++ app i got following error:

c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find   -ladvapi32 
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lshell32 
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -luser32 
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lkernel32 
collect2: ld returned 1 exit status 
make[2]: *** [dist/Debug/MinGW-Windows/welcome_1.exe] Error 1 
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

Can anyone give me a hand with installing openCV and minGW for NetBeans?

解决方案

How to build and use openCV with Netbeans 7.2 . Step by step

Preparations

In the "c:\mingw\bin" and "c:\mingw\lib"

  • Search and delete all libopencv*.dll , libopencv*.dll.a , libopencv*.a

Tested with the following programs

Download OpenCV-2.4.2.exe (222.9 MB) http://sourceforge.net/projects/opencvlibrary/files/
Download mingw-get-inst-20120426.exe (662.7 kB) http://sourceforge.net/projects/mingw/files/
Download cmake-2.8.9-win32-x86.zip http://www.cmake.org/files/v2.8/cmake-2.8.9-win32-x86.zip

All references used in this manual:

All references in this manual begin with "T: \". Please change to the actual drive letter! ( mostly "c:\" )

  • C:\msys\1.0\src --- (If no "msys" exists, create or use "C:\mingw\src").
  • C:\mingw\bin

Note:
I use for new projects in the msys-mingw environment always the "C:\msys\1.0\src" directory.
To have the same conditions, gcc should also be "4.7.0" not "4.6.2"

  • Put at the front of your PATH "C:\mingw\bin;C:\msys\1.0\bin;"

As you've probably noticed, you can not use the libraries that come with OpenCV-2.4.2.exe.
Ignore so the folder "...\opencv\build\x86\mingw\bin" and "...\opencv\build\x86\mingw\lib" completely.

Let's get the new mingw files.

Start mingw-get-inst-20120426.exe

Use : Download latest repository ...

Make sure that the specified directory is correct, usually "C:\mingw".
Check as described below.
If you also need msys, then also select "MinGW Developer Toolkit".

Now MinGW-Get downloads all new files. ( 4.7.0 )

Run "OpenCV-2.4.2.exe".

The folder where the files go should be "c:\msys\1.0\src".
That writes all the files in the new directory "opencv".
The new folder : "C:\msys\1.0\src\opencv". From now on, this is our top-level directory

Open "cmake-2.8.9-win32-x86.zip" and copy the files to your cmake folder.

Creating the Makefiles

Run "C:\cmake\bin\cmake-gui.exe"

  • A: Set the required fields, click "configure"
  • B: Set, click "next"

  • Set and click "ok"

A possible error: sh.exe was found in your PATH

  • A: Error "sh.exe was found in your PATH"
  • B: Search for sh.exe in "C:\msys\1.0\bin" or "C:\mingw\bin" and rename to "shxx.exe"

  • click "configure" again.

A possible error: CMAKE_MAKE_PROGRAM is not set

  • mark "CMAKE_MAKE_PROGRAM" and copy, click "Add Entry"

  • Paste, Set and click "ok"
  • click "configure" again.

Now it should work. Cmake searches the compiler environment

Cmake shows the option page

  • Scroll through the red options. Don't change anything
  • click "configure" again

Let's generate the Makefiles

  • click "Generate"

Building openCV

  • Run "cmd" go to the directory "C:\msys\1.0\src\opencv\build\mingw". There typing "make"

Please wait!

It takes about 4 hours on my computer

Check that all files are in the right place

  • B: *.dll in "C:\msys\1.0\src\opencv\build\mingw\bin"
  • C: *.dll.a in "C:\msys\1.0\src\opencv\build\mingw\lib"

Building an opencv program

  • create a new folder "OpenCV-MakeC" in "C:\msys\1.0\src\opencv"
  • create in the folder "OpenCV-MakeC" a "Makefile" and "imgdisplay.cpp".

To avoid copy and paste error. Here are the 2 files for download:

Makefile

MKDIR_P = C:/msys/1.0/bin/mkdir -p
DESTDIRB = build/Debug
DESTDIRD = dist/Debug
LIBDIRCV = ../build/mingw/lib
CFLAGS = -O2
CXX = C:/mingw/bin/g++.exe
Applic = imgdisplay

ALL: imgdisd

imgdisd:
    $(CXX) $(CFLAGS) -c -g $(Applic).cpp -I../build/include -MMD -MP -MF $(DESTDIRB)/$(Applic).o.d -o $(DESTDIRB)/$(Applic).o
    $(CXX) $(CFLAGS) -o $(DESTDIRD)/$(Applic) $(DESTDIRB)/$(Applic).o -L../build/mingw/bin $(LIBDIRCV)/libopencv_calib3d242.dll.a $(LIBDIRCV)/libopencv_contrib242.dll.a $(LIBDIRCV)/libopencv_core242.dll.a \
    $(LIBDIRCV)/libopencv_features2d242.dll.a $(LIBDIRCV)/libopencv_flann242.dll.a $(LIBDIRCV)/libopencv_gpu242.dll.a $(LIBDIRCV)/libopencv_highgui242.dll.a $(LIBDIRCV)/libopencv_imgproc242.dll.a \
    $(LIBDIRCV)/libopencv_legacy242.dll.a $(LIBDIRCV)/libopencv_ml242.dll.a $(LIBDIRCV)/libopencv_nonfree242.dll.a $(LIBDIRCV)/libopencv_objdetect242.dll.a $(LIBDIRCV)/libopencv_photo242.dll.a \
    $(LIBDIRCV)/libopencv_stitching242.dll.a $(LIBDIRCV)/libopencv_ts242.a $(LIBDIRCV)/libopencv_video242.dll.a $(LIBDIRCV)/libopencv_videostab242.dll.a 
md:
    $(MKDIR_P) "$(DESTDIRB)"
    $(MKDIR_P) "$(DESTDIRD)"

imgdisplay.cpp

/* 
 * File:   imgdisplay.cpp
 * Author: Administrator
 *
 * Created on 14. September 2012, 01:12
 */

#include <cstdlib>
#include <opencv/cv.h>
#include <opencv/highgui.h>

using namespace std;

int main( int argc, char* argv[] ) 
{

    cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); 
    cvMoveWindow("mainWin", 100, 100);
    IplImage* img;
    img = cvLoadImage("D:/grafik/Lightroom/light01.jpg");
    if (!img) {
        std::cout << "Could not open the image file" << std::endl;
        return -1;
    }
    cvShowImage("My Picture", img); 
    cvWaitKey(0);
    cvReleaseImage(&img);
    return 0;
}

Netbeans 7.2 create a project

  • File -- New Project

Use settings as described below.

Created Project

Create a new target

  • Click with the right mouse button on "Makefile"

Note: If you get an error : Makefile:12: *** missing separator. Stop.

Mostly a copy and paste error ! (Make sure no spaces at the start lines. But 2 tab set).

Create new folder

  • Click with the right mouse button on "Makefile"
  • Use the new target "md"

The projects folder now looks like ..

Build the project

Debug the project

  • Copy needed dll's ( C:\msys\1.0\src\opencv\build\mingw\bin to T:\msys\1.0\src\opencv\OpenCV-MakeC\dist\Debug)

  • Open imgdisplay.cpp (double click)
  • Set breakpoint Line 17

    17 cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);

  • Click the Debug button

Program stops on Line 17

Unresolved Identifier

If the source of the .cpp file looks like this

Click with the right mouse button on your project.
Check C/C++ Code As...
Run Reparse Project.

If that is not enough.
Go to Project Properties
Fill in the Include input field as described.

Clean Up

  • If you renamed sh.exe to shxx.exe ! Rename it back !
  • If you have spaces in your PATH Variable, put quotation marks around spaces (only around relevant programs like visual studio and so).
    I know that they are not necessary but one or two programs can't handle the spaces
    in the PATH !!
  • On a

这篇关于NetBeans 7.2 MinGW为OpenCV安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆