MY-IMX Linux-4.1.15 QT5 程序编译手册

来自明远智睿的wiki
Admin讨论 | 贡献2018年8月21日 (二) 11:51的版本

跳转至: 导航搜索


编译主机环境


  • 编译主机CPU架构:64位
  • 编译主机系统:Linux
  • Linux发行版:Ubuntu
  • Ubuntu版本号:14.04.5
  • Ubuntu版本类型:桌面版
  • Ubuntu系统类型:x86-64


安装 SDK


下载 SDK

  在网盘“2.3_系统_Linux-4.1.15/03_工具”目录中下载 SDK 包文件。

  • MY-IMX6-EK140、MY-IMX-EK40P:

  fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa7hf-neon-toolchain-4.1.15-2.1.0.sh

  • MY-IMX6-EK200、MY-IMX-EK314、MY-IMX-EK336:

  fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh

准备安装
  • 把下载的包文件复制到编译主机中。
  • 修改预安装目录的权限
$ chmod 777 /opt -R
SDK 安装(MY-IMX6-EK140、MY-IMX-EK40P)
  • 安装 SDK 包文件
$ ./fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa7hf-neon-toolchain-4.1.15-2.1.0.sh

Freescale i.MX Release Distro SDK installer version 4.1.15-2.1.0
================================================================
Enter target directory for SDK (default: /opt/fsl-imx-fb/4.1.15-2.1.0):
You are about to install the SDK to "/opt/fsl-imx-fb/4.1.15-2.1.0". Proceed[Y/n]? Y
Extracting SDK.......................................................................................................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /opt/fsl-imx-fb/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
  • 创建 oe-device-extra.pri 文件防止 qmake 时报错
$ touch /opt/fsl-imx-fb/4.1.15-2.1.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/oe-device-extra.pri
SDK 安装(MY-IMX6-EK200、MY-IMX-EK314、MY-IMX-EK336)
  • 安装 SDK 包文件
$ ./fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh 
Freescale i.MX Release Distro SDK installer version 4.1.15-2.1.0
================================================================
Enter target directory for SDK (default: /opt/fsl-imx-fb/4.1.15-2.1.0): 
You are about to install the SDK to "/opt/fsl-imx-fb/4.1.15-2.1.0". Proceed[Y/n]? Y
Extracting SDK..............................................................................................................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /opt/fsl-imx-fb/4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
  • 创建 oe-device-extra.pri 文件防止 qmake 时报错
touch /opt/fsl-imx-fb/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/oe-device-extra.pri


编译 QT 应用程序


配置交叉编译工具环境变量
  • MY-IMX6-EK140、MY-IMX-EK40P
$ source /opt/fsl-imx-fb/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
  • MY-IMX6-EK200、MY-IMX-EK314、MY-IMX-EK336
$ source /opt/fsl-imx-fb/4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
准备编译工程
  • 下载 QT Demo 源码包
    在网盘“2.3_系统_Linux-4.1.15/05_MY-Demo”中下载 myzr-qt5-demo.tar 并复制到编译主机中。
  • 解压 QT Demo 源码包
$ tar xf myzr-qt5-demo.tar
  • 进入 QT Demo 工程目录
$ cd myzr-qt5-demo/AboutUs
  • 为工程生成 Makefile
$ qmake
编译工程
  • MY-IMX6-EK140、MY-IMX-EK40P
$ make

/opt/fsl-imx-fb/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/uic widget.ui -o ui_widget.h
......
arm-poky-linux-gnueabi-g++  -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-fb/4.1.15-2.1.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-O1 -o AboutUs main.o widget.o qrc_source.o moc_widget.o   -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lEGL -lpthread
  • MY-IMX6-EK200、MY-IMX-EK314、MY-IMX-EK336
$ make

/opt/fsl-imx-fb/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/uic widget.ui -o ui_widget.h
......
arm-poky-linux-gnueabi-g++  -march=armv7-a -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-fb/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-O1 -o AboutUs main.o widget.o qrc_source.o moc_widget.o   -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lEGL -lpthread
目标可执行文件
  • 查看编译生成的目标文件
$ file AboutUs

AboutUs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=38367b0a95b8fe7402e2377c11626581c07f9c9d, not stripped


运行目标程序


1.把编译生成的 AboutUs 复制到评估板上。

2.运行目标程序

  • MY-IMX6-EK200、MY-IMX-EK314、MY-IMX-EK336
$ ./AboutUs -platform eglfs -plugin evdevtouch:/dev/input/event0

QEglFSVivIntegration will set environment variable FB_MULTI_BUFFER=2 to enable double buffering and vsync.
 If this is not desired, you can override this via: export QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER=1
Unable to query physical screen size, defaulting to 100 dpi.
To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).




--------------------------------------------------------------------------------
* 珠海明远智睿科技有限公司  
* ZhuHai MYZR Technology CO.,LTD.
* Latest Update: 2018/08/21  
* Supporter: Tang Bin
--------------------------------------------------------------------------------