Phytec中国的wiki
support@phytec.cn
热线:0755-61802110-803
预先准备:请将AM335X的BSP更新到PD16.2.0及以上,I.MX6/I.MX6UL的BSP更新到PD16.1.0及以上,
编译和安装好SDK包
怎样用yocto生成SDK,以及SDK使用方法 / yocto how to build SDK and how to use them
以下操作均使用普通用户执行, 不要使用root用户
QT安装
根据下表
点击以上表格中的qt版本中的链接,可下载qt的安装包。
2、设置可执行权限
sudo chmod +x qt‐opensource‐linux‐x64‐5.6.2.run
3、在Qt安装包的目录下,运行Qt安装包
./qt‐opensource‐linux‐x64‐5.6.2.run
4、操作步骤3之后,会打开Qt的安装窗口
Qt的安装目录选择:/opt/Qt/
Qt环境配置
1、安装完成之后,创建Qt Creator的符号链接
sudo ln ‐s /opt/Qt/Tools/QtCreator/bin/qtcreator.sh /usr/bin/qtcreator.sh
2、导入SDK环境到qtcreator.sh中,
sudo vi /opt/Qt/Tools/QtCreator/bin/qtcreator.sh
在qtcreator.sh中增加下面一行
. /opt/phytec‐yogurt/<YOURCONTROLLER>‐PD<YOURPDNR>/environment‐setup‐<YOURARCHITECTURE>‐vfp‐neon‐phytec‐linux‐gnueabi
在. 和绝对路径之间有一个空格
3、创建Qt工程文件夹
mkdir ‐p /opt/prj_workspace/Qt/
4、在命令行中打开qt creator
/usr/bin/qtcreator.sh
5、在菜单栏中选择Tools --> Options --> Devices -->Add --> Generic Linux Device增加linux设备:
Name: ARM IP: 192.168.3.11 Username: root Keep the password empty
注意IP应改为对应板子的IP地址 。
6、设置工程目录和编译目录,选择Tools --> Options --> Build & Run --> General
Projects Directory --> Directory: /opt/prj_workspace/Qt Build and Run --> Default build directory field:../build/%{CurrentProject:Name}
7、选择Tools --> Options --> Build & Run --> Qt Versions,
新建Qt Versions点Add 按钮
Name: ARM_QT qmake Location: /opt/phytec‐yogurt/<YOURCONTROLLER>‐PD<YOURPDNR>/sysroots/x86_64‐yogurtsdk‐linux/usr/bin/qt5/qmake
8、选择Tools --> Options --> Build & Run -->Compilers,点击ADD选择GCC
Name: ARM‐GCC Compiler Path: /opt/phytec‐yogurt/<YOURCONTROLLER>‐PD<YOURPDNR>/sysroots/x86_64‐yogurtsdk‐linux/usr/bin//arm-phytec-linux-gnueabi/arm-phytec-linux-gnueabi-gcc
9、选择Tools --> Options --> Build & Run →Debuggers,点击ADD
Name: ARM‐GDB Path: /opt/phytec‐yogurt/<YOURCONTROLLER>‐PD<YOURPDNR>/sysroots/x86_64‐yogurtsdk‐linux/usr/bin//arm-phytec-linux-gnueabi/arm-phytec-linux-gnueabi-gdb
10、选择Tools --> Options --> Build & Run →Kits,点击ADD
Name: ARM Device Type: Generic Linux Device Sysroot: /opt/phytec‐yogurt/<YOURCONTROLLER>‐PD<YOURPDNR>/sysroots/<YOURARCHITECTURE>‐vfp‐neon‐phytec‐linux‐gnueabi Compiler: ARM_GCC Debugger: ARM_GDB Qt version: ARM_QT Qt mkspec: linux‐oe‐g++
11、选择Tools --> Options --> Debugger →GDB
在Addition Startup Commands输入下列命令:
set auto‐load safe‐path / handle SIGILL nostop
12、点击Apply,然后点击OK关闭配置窗口。现在已经完成所有的配置,可以使用这个Kit来交叉编译qt工程。
使用qt交叉编译新建工程
1、操作之前通过串口关闭phytec-qtdemo.service
systemctl stop phytec-qtdemo.service
2、在命令行中输入以下命令打开Qt Creator
/usr/bin/qtcreator.sh &
3、新建qt工程,在Kit Selection选择ARM
4、qt工程编写完成后,点击左边绿色三角形按钮可以编译和运行程序在开发板上。
如果需要在开发板上运行和调试qt程序, 需先将开发板上的qtdemo程序先关闭
systemctl stop phytec-qtdemo.service
调试Qt程序
1、修改工程的.pro文件,在.pro文件中增加以下两行
target.path = /home/root/ INSTALLS += target
target.path为开发板的qt编译后文件的目录
2、点击左边的灰色按钮将Qt的编译配置从Relese改为Debug模式
3、确保开发板和linux主机能互ping通,点击左边的调试按钮进入调试模式