Error when using pkg-config in qmake file



  • Here is qmake file:

    TEMPLATE = app
    QT += qml quick widgets
    CONFIG += c++11
    
    SOURCES += main.cpp \
        backend.cpp
    
    HEADERS += \
        backend.h
    
    RESOURCES += qml.qrc
    
    INCLUDEPATH +=`pkg-config --cflags opencv`
    LIBS += `pkg-config --libs opencv`
    
    #INCLUDEPATH += /usr/local/opencv_itseesz/include
    #LIBS += /usr/local/opencv_itseesz/lib/*.so
    
    

    When using pkg-config tool to find opencv, error occured:

    /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qapplication.h:37: error: QtCore/qcoreapplication.h: No such file or directory
     #include <QtCore/qcoreapplication.h>
                                         ^
    

    But when not using the pkg-config, like the two commonted lines below, it worked well.

    So, if there is any bugs when using pkg-config in qmake?

    BTW, "pkg-config --cflags --libs opencv" works fine in terminal.

    Thanks.



  • That is not how you use pkg-config with qmake.
    Check qmake manual: http://doc.qt.io/qt-5/qmake-project-files.html#configuration-features
    You enable pkg-config linking with

    CONFIG += link_pkgconfig
    

    and select packages to use with

    PKGCONFIG += <package1> <package2>...
    


  • Much thanks!!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.