Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

openCV in Qt Creator on Mac



  • I tried linking openCV to my Qt project by editing the project file which now reads:

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = image
    TEMPLATE = app
    
    DEFINES += QT_DEPRECATED_WARNINGS
    
    CONFIG += c++11
    
    SOURCES += \
            main.cpp \
            mainwindow.cpp
    
    HEADERS += \
            mainwindow.h
    
    FORMS += \
            mainwindow.ui
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    QT_CONFIG -= no-pkg-config
    CONFIG  += link_pkgconfig
    PKGCONFIG += opencv
    INCLUDEPATH += \
        /usr/local/include
    LIBS += `pkg-config --libs opencv`
    PKG_CONFIG = /usr/local/bin/pkg-config
    
    LIBS += \
        -L/usr/local/lib \
        -lopencv_core \
        -lopencv_highgui
    

    But upon trying to run it I get the error:

    :-1: error: opencv development package not found

    I m using Mac version 10.14.5 , OpenCV version 2.4.13.

    [Edit aha_1980: Added code tags]


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You are mixing several things together. Just use the dedicated variable.

    Next, where is the opencv.pc file located on your system ?


Log in to reply