简体   繁体   中英

Adding openCV .dll files to Netbeans C++ Qt application

I am developing software where I need to use the OpenCV libraries under NetBeans. Took 2 days to be able to run correctly a C++ Application with OpenCV.

In a C++ Application I needed to add C:/OpenCV245/build/include in project properties->Build->C++ compiler-> Include Directories and Headers. Also, Under the Linker properties-> Additional Library Directories I had to add the following directories

  • C:/OpenCV245/release/lib
  • C:/OpenCV245/build/x64/mingw/lib

    and add the .dll files I specifically needed in the linker->libraries

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"...

I tried building to see what errors would pop:

cannot find -lopencv_core245.dll
cannot find -lopencv_highgui245.dll

How do we add .dll.a files to a C++ Qt application under Netbeans?


Programming environment:

  • NetBeans 7.4

  • MinGW 3.2 Compiler c++ compiler, msys make command and qt5.1.1 qmake for Qmake Command

  • Qt5.1.1

  • OpenCV2.4.5

  • Windows 8 64 bit

It appears as if you are trying to link with the *.DLL files instead of *.LIB files. 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.
  2. Compile your program so you get an *.EXE
  3. Put the relevant *.DLL-files in the same folder as the *.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. 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 +=

+Under Project Properties-> Build -> C++ Compiler in Include Directories and Headers add the appropriate path for the includes. ex: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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