Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cant get OpenCV Version 4 to be compiled with my app.
QtWS25 Last Chance

Cant get OpenCV Version 4 to be compiled with my app.

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.1k Views
  • 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.
  • A Offline
    A Offline
    ademmler
    wrote on 27 Apr 2020, 16:35 last edited by
    #1

    Hi there,

    I have problems using opencv4 on mac os x.
    Any help and hints are welcome.
    Thx in advance!
    Alexander

    I have used two different ways of installation for opencv4:

    1. I tried using Macports with this in my .pro file:
    CONFIG  += link_pkgconfig
    PKGCONFIG += opencv4
    INCLUDEPATH += /opt/local/include
    LIBS += `pkg-config --cflags --libs`
    

    The error i get is this:
    Project ERROR: opencv4 development package not found
    18:17:05: The process "/Applications/Qt/5.12.6/clang_64/bin/qmake" exited with code 3.
    Error while building/deploying project spectraproof2 (kit: Desktop Qt 5.12.6 clang 64bit)

    1. I compiled and installed it to /usr/local ... from source.
      Because this does not provide opencv4.pc (pkg-config file) i set options in .pro file manually:
    INCLUDEPATH += /usr/local/include
    LIBS += -L/usr/local/lib \
             -lopencv_core \
             -lopencv_highgui
    

    The error i get is this:
    Undefined symbols for architecture x86_64:
    "cv::namedWindow(cv::String const&, int)", referenced from:
    MainWindow::onImageUpdateNeeded() in mainwindow.o
    "cv::String::deallocate()", referenced from:
    cv::String::~String() in main.o
    cv::String::operator=(cv::String const&) in main.o
    cv::String::~String() in mainwindow.o
    cv::String::operator=(cv::String const&) in mainwindow.o
    cv::String::~String() in moc_mainwindow.o
    cv::String::operator=(cv::String const&) in moc_mainwindow.o
    "cv::String::allocate(unsigned long)", referenced from:
    cv::String::String(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in mainwindow.o
    cv::String::String(char const*) in mainwindow.o
    "cv::imread(cv::String const&, int)", referenced from:
    MainWindow::on_actionOpenImage_triggered() in mainwindow.o
    "cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from:
    MainWindow::onImageUpdateNeeded() in mainwindow.o
    "cv::imwrite(cv::String const&, cv::_InputArray const&, std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
    MainWindow::on_actionSaveImage_triggered() in mainwindow.o
    "cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)", referenced from:
    MainWindow::processImage(cv::Mat const&, cv::Mat&) in mainwindow.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [SpectraProof.app/Contents/MacOS/SpectraProof] Error 1
    18:29:51: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project spectraproof2 (kit: Desktop Qt 5.12.6 clang 64bit)

    1 Reply Last reply
    0
    • S SGaist
      29 Apr 2020, 18:27

      That file is generated as part of building / installing the library.

      It looks like it's in a non standard path, you likely need to modify the PKG_CONFIG_PATH environment variable.

      A Offline
      A Offline
      ademmler
      wrote on 30 Apr 2020, 10:37 last edited by ademmler
      #5

      @SGaist

      As I said opencv community has dropped png-config support.
      Hence I needed to recompile with opencv4.pc file.
      This one needed manual fixing of th path ...
      Now it works - for me at least. thx for your help

      Another - even easier solution is to configure *.pro by hand:

      unix: macx{
      DEPENDPATH += /usr/local/lib
      INCLUDEPATH += /usr/local/include/opencv4
      += /usr/local/include/opencv4/opencv2
      LIBS += -L/usr/local/lib
      -lopencv_calib3d
      -lopencv_core
      -lopencv_dnn
      -lopencv_features2d
      -lopencv_flann
      -lopencv_gapi
      -lopencv_highgui
      -lopencv_imgcodecs
      -lopencv_imgproc
      -lopencv_ml
      -lopencv_objdetect
      -lopencv_photo
      -lopencv_stitching
      -lopencv_video
      -lopencv_videoio
      }

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 27 Apr 2020, 17:19 last edited by
        #2

        Hi,

        Where is the opencv4.pc file located on your system ?

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

        A 1 Reply Last reply 29 Apr 2020, 07:29
        0
        • S SGaist
          27 Apr 2020, 17:19

          Hi,

          Where is the opencv4.pc file located on your system ?

          A Offline
          A Offline
          ademmler
          wrote on 29 Apr 2020, 07:29 last edited by
          #3

          @SGaist

          Hi, thx for responding.

          opencv4 does not provide opencv4.pc

          If you use self compiled packages it should be in /usr/local/lib/pkg-config.
          If you use Macports it should be in /opt/local/lib/pkg-config

          Output from png-config:
          -I/opt/local/include/opencv4/opencv -I/opt/local/include/opencv4 -L/opt/local/lib -lopencv_dnn -lopencv_gapi -lopencv_highgui -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_video -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_videoio -lopencv_imgcodecs -lopencv_imgproc -lopencv_core

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 29 Apr 2020, 18:27 last edited by
            #4

            That file is generated as part of building / installing the library.

            It looks like it's in a non standard path, you likely need to modify the PKG_CONFIG_PATH environment variable.

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

            A 1 Reply Last reply 30 Apr 2020, 10:37
            0
            • S SGaist
              29 Apr 2020, 18:27

              That file is generated as part of building / installing the library.

              It looks like it's in a non standard path, you likely need to modify the PKG_CONFIG_PATH environment variable.

              A Offline
              A Offline
              ademmler
              wrote on 30 Apr 2020, 10:37 last edited by ademmler
              #5

              @SGaist

              As I said opencv community has dropped png-config support.
              Hence I needed to recompile with opencv4.pc file.
              This one needed manual fixing of th path ...
              Now it works - for me at least. thx for your help

              Another - even easier solution is to configure *.pro by hand:

              unix: macx{
              DEPENDPATH += /usr/local/lib
              INCLUDEPATH += /usr/local/include/opencv4
              += /usr/local/include/opencv4/opencv2
              LIBS += -L/usr/local/lib
              -lopencv_calib3d
              -lopencv_core
              -lopencv_dnn
              -lopencv_features2d
              -lopencv_flann
              -lopencv_gapi
              -lopencv_highgui
              -lopencv_imgcodecs
              -lopencv_imgproc
              -lopencv_ml
              -lopencv_objdetect
              -lopencv_photo
              -lopencv_stitching
              -lopencv_video
              -lopencv_videoio
              }

              1 Reply Last reply
              0

              1/5

              27 Apr 2020, 16:35

              • Login

              • Login or register to search.
              1 out of 5
              • First post
                1/5
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved