明遠智睿I.MX6 Linux-4.1.15 QT5 程式編譯手冊
編譯主機環境
- 編譯主機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).