Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Using QT with openCV on Maverick osX
Forum Updated to NodeBB v4.3 + New Features

Using QT with openCV on Maverick osX

Scheduled Pinned Locked Moved Installation and Deployment
8 Posts 2 Posters 5.0k 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.
  • B Offline
    B Offline
    Ben_Pflaenz
    wrote on last edited by
    #1

    Hello

    I am new to openCV and I would like to install openCV and use it with QT.
    I used macports to install it and i set the path in the terminal.

    What I did was;

    I installed macports
    I typed in the terminal
    @
    export PATH=$PATH:/opt/local/bin
    source .profile
    sudo port -v selfupdate
    sudo port install opencv
    @
    restart
    Thats all...

    Now i try to compile a Helloworld but i get unknown variable error. Looks like something with the linker gone wrong or i included the wrong libs? I searched google and I found some hints but nothing helped yet. Maybe someone got a suggestion?
    Thank you very much for your time and answer!

    My settings:
    @
    #-------------------------------------------------
    #
    # Project created by QtCreator 2014-02-04T22:10:07
    #
    #-------------------------------------------------

    QT       += core
    
    QT       -= gui
    
    TARGET = opencvTest
    CONFIG   += console
    CONFIG   -= app_bundle
    
    TEMPLATE = app
    
    SOURCES += main.cpp
    
    INCLUDEPATH += /opt/local/include
    
    LIBS += -L/opt/local/lib
    LIBS += -lopencv_core
            -lopencv_highgui
    

    @

    @
    #include <iostream>
    #include <opencv2/highgui/highgui.hpp>

    using namespace std ;
    using namespace cv ;
    
    int main()
    {
        Mat img ;
    
        img = imread("unknown.jpg") ;
    
        return 0;
    }
    

    @
    Error message

    @
    10:39:10: Running steps for project opencvTest...
    10:39:10: Configuration unchanged, skipping qmake step.
    10:39:10: Starting: "/usr/bin/make"
    /Users/Ben/Qt/5.2.0/clang_64/bin/qmake -spec macx-g++ CONFIG+=debug CONFIG+=x86 CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile ../opencvTest/opencvTest.pro
    /Applications/Xcode.app/Contents/Developer/usr/bin/g++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -o opencvTest main.o -F/Users/Ben/Qt/5.2.0/clang_64/lib -L/opt/local/lib -lopencv_core -framework QtCore
    Undefined symbols for architecture x86_64:
    "cv::imread(std::string const&, int)", referenced from:
    _main in main.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: *** [opencvTest] Error 1
    10:39:10: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project opencvTest (kit: Unnamed)
    When executing step 'Make'
    10:39:10: Elapsed time: 00:00.@

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

      Hi and welcome to devnet,

      Check your opencv install to see if it was build for x86_64

      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
      • B Offline
        B Offline
        Ben_Pflaenz
        wrote on last edited by
        #3

        Hmm it should be, Macport installs it as a 64bit as default as I know from google.
        I don't know how I can check that honestly.

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

          call

          @file /opt/local/lib/libopencv_core.dylib@

          in your console

          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
          • B Offline
            B Offline
            Ben_Pflaenz
            wrote on last edited by
            #5

            so....
            /opt/local/lib/libopencv_core.dylib: Mach-O 64-bit dynamically linked shared library x86_64

            thats the result so I think its the right one? isn't it?

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Ben_Pflaenz
              wrote on last edited by
              #6

              Yeaah it works! Finally!

              /Users/Ben/Qt/5.2.0/clang_64/mkspecs/macx-clang/qmake.conf
              

              had to change

              QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
              

              to

              QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
              
              1 Reply Last reply
              0
              • B Offline
                B Offline
                Ben_Pflaenz
                wrote on last edited by
                #7

                BUT... other libs like boost won't work anymore...

                I have to add
                QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
                to the pro file in the project for the opencv projects separately

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

                  You'll have to check that all your libraries have the same deployment target. That might also mean rebuild Qt

                  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 Extensions
                  • Unsolved