Important: Please read the Qt Code of Conduct -

Error when using pkg-config in qmake file

  • Here is qmake file:

    TEMPLATE = app
    QT += qml quick widgets
    CONFIG += c++11
    SOURCES += main.cpp \
    HEADERS += \
    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.


  • That is not how you use pkg-config with qmake.
    Check qmake manual:
    You enable pkg-config linking with

    CONFIG += link_pkgconfig

    and select packages to use with

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

  • Much thanks!!!

Log in to reply