MyProgram.pro文件配置如下:
#-------------------------------------------------
#
# Project created by QtCreator 2017-03-30T14:03:51
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
# The name of created app progarm
TARGET = MyProgram
CONFIG += qt warn_off
# app or lib
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
#mysql ------------------------------------------------------------------------------------------------------------------------------
QT += sql
# caffe -------------------------------------------------------------------------------------------------------------------------------
INCLUDEPATH += /home/nielsen/caffe-master/include \
/opt/intel/compilers_and_libraries/linux/mkl/include
LIBS += -L/home/nielsen/caffe-master/build/lib
LIBS += -lcaffe
# CPU_ONLY
DEFINES += CPU_ONLY
# cuda (when use GPU) ---------------------------------------------------------------------------------------------------------
# INCLUDEPATH += /usr/local/cuda/include
# LIBS += -L/usr/local/cuda/lib64
# LIBS += -lcudart -lcublas -lcurand
# opencv (in preject folders) ---------------------------------------------------------------------------------------------------
INCLUDEPATH += ./include/opencv\
./include/opencv2
LIBS += /usr/local/lib/libopencv_highgui.so.2.4.10 \
/usr/local/lib/libopencv_core.so.2.4.10 \
/usr/local/lib/libopencv_imgproc.so.2.4.10 \
/usr/local/lib/libopencv_calib3d.so.2.4.10 \
/usr/local/lib/libopencv_features2d.so.2.4.10 \
/usr/local/lib/libopencv_flann.so.2.4.10 \
/usr/local/lib/libopencv_gpu.so.2.4.10 \
/usr/local/lib/libopencv_legacy.so.2.4.10 \
/usr/local/lib/libopencv_ml.so.2.4.10 \
/usr/local/lib/libopencv_objdetect.so.2.4.10 \
/usr/local/lib/libopencv_video.so.2.4.10 \
/usr/local/lib/libopencv_contrib.so.2.4.10
LIBS += -lopencv_core -lopencv_imgproc -lopencv_highgui
# other dependencies -------------------------------------------------------------------------------------------------------------
LIBS += -lglog -gflags -lprotobuf -lboost_system -lboost_thread -llmdb -lleveldb -lstdc++ -lcblas -latlas
# Optional------------------------------------------------------------------------------------------------------------------------------
# The path of the created app program
# DESTDIR +=
# The config information
# CONFIG += qt warn_on debug release thread x11 plugin
# The path of making the .ui file to the ui_*.h file
# UI_DIR +=
# The path of making the .qrc file to the qrc_*.h file
# RCC_DIR +=
# The path of making the Q_OBJECT file to the .h file
# OBJECTS_DIR +=
# The other dependent paths of the codes compiled
# DEPENDPATH +=
# The way of codes compiled
# CODECFORSRC += GBK
# The resource file of including in project (.qrc)
# RESOURCES +=
# Add file that cound be used
# DISTFILES +=
# Add .ico (txt -> qtdemo.rc : IDI_ICON1 ICON DISCARDABLE "start.ico") (.rc)
# RC_FILE = qtdemo.rc
# LANGUAGE = C++
# IMAGES = 1.png \
# 2.png
---------------------------------------------------------------------------------------------------------------------------------------
mainwindow.cpp头文件配置如下:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace cv;
using namespace caffe;
----------------------------------------------------------------------------------------------------------------------------------------
.pro文件中各变量意义:
1.HEADERS 指定工程的 C++头文件(.h)。
2. SOURCES 指定工程的C++实现文件(.cpp)。
3. FORMS 指定需要 uic 处理的由 Qt 设计师生成的.ui 文件。
4. RESOURCES 指定需要 rcc 处理的.qrc 文件。
5. DEFINES 指定预定义的 C++预处理符号。
6. INCLUDEPATH 指定 C++编译器搜索全局头文件的路径。
7. LIBS 指定工程要链接的库。库既可以通过绝对路径指定,也可以使用源自 Unix 的-L 和-l 标识符来指定(例如,-L/usr/local/lib 和-ldb_cxx)。
8. CONFIG 指定各种用于工程配置和编译的参数。
9. QT 指定所要使用的 Qt 模块(默认是 core gui,对应于 QtCore 和 QtGui 模块)。
10. VERSION 指定目标库的版本号。
11.TARGET 指定可执行文件或库的基本文件名,其中不包含任何的扩展、前缀或版本号(默认的是当前的目录名)。
12. DESTDIR 指定可执行文件放置的目录(默认值是平台相关的。 例如,在 Linux 上,指当前目录;在 Windows 上,则是指 debug 或 release 子目录)。
13. DLLDESTDIR 指定目标库文件放置的目录(默认路径与 DESTDIR 相同)。 CONFIG 变量用来控制编译过程中的各个方面。它支持下面这些参数:
14. debug 是指具有调试信息的可执行文件或者库,链接 Qt 库的调试版。
15.release 是指编译不具有调试信息的可执行文件或者库,链接发行版的 Qt 库。如果同时指定 debug 和 release,则 debug 有效。
16.warn_off 会关闭大量的警告。默认情况下,警告的状态是打开的。
17.qt 是指应用程序或者库使用 Qt。这一选项是默认包括的。
18.dll 是指动态编译库。
19.staticlib 是指静态编译库。
20.plugin 是指编译一个插件。插件总是动态库,因此这一参数暗含 dll 参数。
21.console 是指应用程序需要写控制台(使用 cout、cerr、qWarning(),等等)。
22.app_bundle 只适用于 Mac OS X 编译,是指可执行文件被放到束中,这是 Mac OS X 的默认情况。
23. lib_bundle 只适用于 Mac OS X 编译,指库被放到框架中。