记录一下,以备以后查阅。
其中以opencv库为例:
1.#指定库的头文件所在路径,hpp为c++中放头文件声明的拓展名
INCLUDEPATH += $$PWD/../opencv/include
2.#指明依赖库关系,静态库名有d的放在debug下
LIBS += -L$$PWD/../opencv/lib/x64 -lopencv_world451
语法为:# LIBS += -L'路径' -l库名
或
win32 {
QMAKE_CFLAGS_RELEASE = -O2 -MD -Zi
QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO /DEBUG
QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO
#CONFIG变量,可以配置各种所要求的属性变量
CONFIG(debug,debug|release){
#DESTDIR指定生成文件路径
DESTDIR = $$absolute_path($${_PRO_FILE_PWD_}/../x64/Debug/)
LIBS += -L$$PWD/../opencv/lib/x64 -lopencv_world451d
} else {
DESTDIR = $$absolute_path($${_PRO_FILE_PWD_}/../x64/Release/)
LIBS += -L$$PWD/../opencv/lib/x64 -lopencv_world451
}
}
3.将dll动态库放到生成的exe执行文件同级目录下