Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt and OpenCV
Qt 6.12 LTS is out! See what's new in the release blog

Qt and OpenCV

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I'm attempting to use OpenCV 248 within my Qt Creation application and am hitting a linking snag. In the .pro file I have the following defined:

    @#--------------- specifying opencv libs -----------------

    CV_LIB_PATH = ../../Libs/x64/opencv/build/x64/vc12/staticlib/
    CV_VERSION = 248
    CV_LIBS += opencv_core
    opencv_features2d
    opencv_highgui
    opencv_imgproc \

    #--------------------------------------------------------

    CV_DEBUG =
    debug {
    CV_DEBUG += d
    }

    cvpaths =
    cvlibs =
    for(libName, CV_LIBS){
    cvpaths += -L$${CV_LIB_PATH}$${libName}$${CV_VERSION}$${CV_DEBUG}
    cvlibs += -l$${libName}$${CV_VERSION}$${CV_DEBUG}
    }

    INCLUDEPATH += ../../Includes
    ../../Includes/opencv/includes
    LIBS += $${cvpaths} $${cvlibs}@

    -and qmake seems to find everything just fine, no errors. Then in an unassuming object file:

    @#include "autoslicer.h"
    #include "opencv2/core/core.hpp"

    Autoslicer::Autoslicer()
    {
    cv::Mat2d a;

    }
    @

    It finds the include just fine. So I know I've got my path's right.
    When I go to build I get a bunch of unresolved's for instantiating that Mat2d. What did I miss? Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It looks like you have too many \ in your pro file which might be interfering. First thing to do is remove them to be sure that your pro file is clean.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Good eye! Now I'm getting complaints about it not being able to open the file... so it would seem my paths WERE wrong. Thanks!

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          So this is strange. Qt can't seem to locate these libraries. I even placed them in the same directory as my .pro, changed the CV_LIB_PATH variable to "". Then I ran qmake with -d (verbose) and checked the following line to be correct:

          @LIBS := -Lopencv_core248d -Lopencv_features2d248d -Lopencv_highgui248d -Lopencv_imgproc248d -lopencv_core248d -lopencv_features2d248d -lopencv_highgui248d -lopencv_imgproc248d@

          These .lib files are as is in the same directory as the .pro, which baffles me as to why I still get a

          @:-1: error: LNK1104: cannot open file 'opencv_core248d.lib'@

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Don't you have all opencv lib files in only one folder ?

            @LIBS += -L$$CV_LIB_PATH@

            Should be the only path needed

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Yeah, I figured out that I was confused with the meaning of the linker options -L and -l. -L points to a directory and then you can use -l for the individual libs, something I didn't totally get. I ended up just expressing the libs without options and used their direct path.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                So you go it working ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt
                • Unsolved