简体   繁体   English

将openCV .dll文件添加到Netbeans C ++ Qt应用程序

[英]Adding openCV .dll files to Netbeans C++ Qt application

I am developing software where I need to use the OpenCV libraries under NetBeans. 我正在开发需要在NetBeans下使用OpenCV库的软件。 Took 2 days to be able to run correctly a C++ Application with OpenCV. 花了2天的时间才能使用OpenCV正确运行C ++应用程序。

In a C++ Application I needed to add C:/OpenCV245/build/include in project properties->Build->C++ compiler-> Include Directories and Headers. 在C ++应用程序中,我需要在项目属性->构建-> C ++编译器->包含目录和标题中添加C:/ OpenCV245 / build / include。 Also, Under the Linker properties-> Additional Library Directories I had to add the following directories 另外,在链接器属性->其他库目录下,我必须添加以下目录

  • C:/OpenCV245/release/lib C:/ OpenCV245 / release / lib目录
  • C:/OpenCV245/build/x64/mingw/lib C:/ OpenCV245 /编译/ X64 / MinGW的/ lib目录

    and add the .dll files I specifically needed in the linker->libraries 并在链接器->库中添加我特别需要的.dll文件

Now when I try to create a C++ Qt application, I add the proper include directories and headers but I can't add the path to my "additional libraries"... 现在,当我尝试创建C ++ Qt应用程序时,我添加了适当的包含目录和标头,但无法将路径添加到“其他库”中。

I tried building to see what errors would pop: 我尝试构建以查看会弹出什么错误:

cannot find -lopencv_core245.dll 找不到-lopencv_core245.dll
cannot find -lopencv_highgui245.dll 找不到-lopencv_highgui245.dll

How do we add .dll.a files to a C++ Qt application under Netbeans? 我们如何将.dll.a文件添加到Netbeans下的C ++ Qt应用程序中?


Programming environment: 编程环境:

  • NetBeans 7.4 NetBeans 7.4

  • MinGW 3.2 Compiler c++ compiler, msys make command and qt5.1.1 qmake for Qmake Command MinGW 3.2编译器c ++编译器,msys make命令和Qmake命令的qt5.1.1 qmake

  • Qt5.1.1 Qt5.1.1

  • OpenCV2.4.5 OpenCV2.4.5

  • Windows 8 64 bit Windows 8 64位

It appears as if you are trying to link with the *.DLL files instead of *.LIB files. 似乎您正在尝试链接* .DLL文件而不是* .LIB文件。 The right way to go is to: 正确的方法是:

  1. In the linker->libraries settings link to the *.LIB files you need instead of the *.DLL files. 在链接器->库设置中,链接到所需的* .LIB文件,而不是* .DLL文件。
  2. Compile your program so you get an *.EXE 编译您的程序,以便得到一个* .EXE
  3. Put the relevant *.DLL-files in the same folder as the *.EXE 将相关的* .DLL文件与* .EXE放在同一文件夹中
  4. The program is now runnable if you double-click its icon in the file browser. 现在,如果您在文件浏览器中双击该程序的图标,则该程序可运行。

It the program refuses to run from Netbeans but it works from the file browser, then that is because you need to tell Netbeans what the "current working directory" is when you launch the program in debug mode. 如果程序拒绝从Netbeans运行,但是可以从文件浏览器运行,那是因为在调试模式下启动程序时,您需要告诉Netbeans“当前工作目录”是什么。 This setting should be available in some settings dialog. 此设置应该在某些设置对话框中可用。

+Under Project Properties-> Build -> Qt go to Expert Custom Definitions add add the path to the appropriate .dll.a files with the LIBS += 在“ 项目属性”->“构建”->“ Qt”下,转到“专家自定义定义”,然后使用LIBS + =将路径添加到相应的.dll.a文件中。

+Under Project Properties-> Build -> C++ Compiler in Include Directories and Headers add the appropriate path for the includes. 包含目录和标头中的 +在“ 项目属性”->“生成”->“ C ++编译器”下 ,为包含添加适当的路径。 ex: C:\\OpenCV\\build\\include 例如:C:\\ OpenCV \\ build \\ include

+Under Project Properties-> Build -> Linker click on Libraries then Add Library File... ( NOT ADD LIBRARY) and add the appropriate .dll.a files that were included in the first point. 在“ 项目属性”->“构建”->“链接器”下,单击“库”,然后添加“添加库文件...”(不添加库),并添加第一点中包含的相应.dll.a文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM