目录
系统:Ubuntu16.04LTS
编译器:qt5.x
python: ubuntu系统自带3.x版本
1.安装qt软件
建议通过安装包方式安装,通过apt的方式安装会有一点问题
2. python解释器
不要使用anaconda,我使用anaconda环境创建的python,使用C++调用python时会出现一些问题,比如在python中无法导入第三方库,比如numpy, cv2, twnsorflow等等。
使用系统默认自带的,如果系统没有,则直接安装python,并将python默认安装在usr路径下
3. 配置qt .pro文件
1. 先创建一个qt C++工程,将头文件,源文件,python文件都加载进来
2. 将python头文件和路径加载进来
库文件: usr/lib/python3.5/config-3.5m-x86_64-linux-gnu 然后选择libpython3.5m.a
包含路径:/usr/include/python3.5
将这两个路径弄好后,后面还需要将两个库手动加入。
可以看到上图第一行最后有三个库,第一个python3.5m是前面添加的,最后两个dl, util需要手动加上,手打加上就可以,不加也可以,主要为了防止可能出现的错误。
如果要使用tensorflow,或别的深度学习框架,需要调用cuda, 需要将cuda 的路径也加载进来
qt .pro整体配置如下:
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to co