简体   繁体   中英

QT 5.9 and Opencv Error

I have a QT/Opencv project that worked great with Visual Studio 2015 and Qt 5.6. Since I bought a new pc, I installed Visual Studio 2017 and the new Qt 5.9. If I try to import the project and to compile it, I get a huge list of LNK2019 and LNK2001 errors on Opencv calls. I've already checked that QT founds the correct compile and the platform is right (x64), and also checked that the Opencv includes are correctly found.

Which other checks I should do?

I'm using Windows 10, Qt Creator 4.4.1 and Visual Studio 2017 Community.

As @DimChtz and @drescherjm said in comments, the problem was the .lib linking. In the previous version of QT, I linked the library in this way: LIBS += -L"path/opencv_world331.lib" . In order to make it work, I just removed the -L parameter.

The EASIEST and most SIMPLE method of ensuring your OpenCV libraries (all external libraries) are linked with Qt is to use the "Add Library..." option.

The steps listed below are found in the Qt5 documentation: [ http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html][1] under the "To Add Library" section.

  1. Right click on the project file located in the 'project pane' on the left side of the creator... and select "Add Library..."
  2. Follow the instructions of the wizard

Let me add some specificity from here...

  1. Select "External Library"
  2. For the "Library File" navigate to your opencv_worldXXX.lib file (or opencv_worldXXXd.lib file, you will notice that by specifying only one or the other the wizard has a checkbox which includes the other automatically) [ex. ...\\opencv\\build\\x64\\vc12\\lib\\opncv_world.lib]
  3. For the "Include Folder" navigate to the "include" folder within the build. [ex. ...\\opencv\\build\\include]
  4. Select your operating system, dynamic/static library (whichever is appropriate)
  5. Hit NEXT, CLEAN UP, and RUN!

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