1) You can create a .prf (project feature) file in your mkspecs/features
directory:
/usr/share/qt5/mkspecs/features/opencv.prf
INCLUDEPATH += -I/usr/local/include/opencv
LIBS += -L/usr/local/lib -lopencv_stitching -lopencv_superres ...and another libraries
Now simply add CONFIG += opencv
to your .pro file to have it working. Or you can even auto-enable this feature by editing mkspecs/qconfig.pri
:
/usr/share/qt5/mkspecs/qconfig.pri
...
CONFIG += ... opencv
...
BTW. qconfig.pri
is a part of qt_config
, which is loaded by all QMake's machine-dependent specs, so it should always work. However, it's also possible to patch only a specific spec (for example, /usr/share/qt5/mkspecs/linux-g++/qmake.conf
, or whatever is appropriate for your configuration). Of course, it's even possible to add all these INCLUDEPATH+=...
and LIBS+=...
straight into that qmake.conf
and get rid of the .prf file completely.
2) Alternatively, if you don't want to pollute Qt installation, you can use manual include:
opencv.pri
INCLUDEPATH += -I/usr/local/include/opencv
LIBS += -L/usr/local/lib -lopencv_stitching -lopencv_superres ...and another libraries
myprogram.pro
include(path/to/opencv.pri)
...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…