qt4.8.6 移植到 freescale (arm 平台)

----------------------------------------
1. 准备arm 交叉编译工具链
----------------------------------------
我有 imx283 平台,
选择其附带的 gcc-4.4.4-glibc-2.11.1-multilib-1.0_EasyARM-iMX283.tar.bz2 交叉编译工具链
我把工具链解压到/opt目录,在.bashrc 中添加bin目录路径到path 中
export PATH=$PATH:/opt/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin

----------------------------------------
2. 准备 qt4.8.6 源码
----------------------------------------
下载 qt-everywhere-opensource-src-4.8.6.tar.gz 源码
我把它解压到~/source 目录

----------------------------------------
3. 编写一个编译脚本, 方便编译
----------------------------------------
进入源码目录,编辑一个编译脚本文件 build_qt.sh, 如下所示:
hjj@hjj-Inspiron:~/source/qt-everywhere-opensource-src-4.8.6$ cat build_qt.sh
#!/bin/bash 
./configure -prefix /opt/qtenv/qt-4.8.6-arm -opensource -confirm-license -embedded arm -xplatform qws/linux-arm-g++ -platform qws/linux-x86-g++ -little-endian -host-little-endian -shared -no-qt3support -no-phonon -no-phonon-backend -qt-zlib -no-gif -no-libtiff -no-qvfb -qt-libjpeg -no-nis -no-opengl -no-cups -no-webkit -no-glib -no-dbus -no-rpath -no-mmx -no-3dnow -no-sse -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-neon -no-audio-backend -no-svg -no-javascript-jit -no-script -no-scripttools -no-multimedia -no-openssl -nomake tools

这个脚本要说明一下: (./configure --help 有帮助,但不全)
-opensource //就是说我们用开源的代码, 不想花钱了
-prefix //是指定的安装根目录
-embeded arm  //指定为嵌入式系统编译,为arm cpu 编译
-xplatform qws/linux-arm-g++  //说明交叉编译平台类型
我们进入 mkspecs/qws/linux-arm-g++ 目录, 查看qmake.conf
$cat qmake.conf
#
# qmake configuration for building with arm-linux-g++
#

include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
include(../../common/qws.conf)

# modifications to g++.conf
QMAKE_CC                = arm-linux-gcc
QMAKE_CXX               = arm-linux-g++
QMAKE_LINK              = arm-linux-g++
QMAKE_LINK_SHLIB        = arm-linux-g++

# modifications to linux.conf
QMAKE_AR                = arm-linux-ar cqs
QMAKE_OBJCOPY           = arm-linux-objcopy
QMAKE_STRIP             = arm-linux-strip
查看arm-linux-gcc 所在路径:
$which arm-linux-gcc
/opt/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-linux-gcc
$ ls -l /opt/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-linux-gcc
/opt/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-linux-gcc -> arm-fsl-linux-gnueabi-gcc

这样我们验证了编译器是 arm-fsl-linux-guneabi-gcc, 一切看起来都是ok的

-platform qws/linux-x86-g++ 指明主机编译平台, 我的机器,32,64位编译都支持,两套库都齐全,就选它了。
其它选项,比较简单,为了编译出最小系统。

----------------------------------------
4. 配置,编译,安装
----------------------------------------
$ . build_qt.sh
$ make
$ make install

配置的时候,我们看到有很多project, (.pro文件)
make 时间会比较长。make install 很短。
一切都是很顺利的。
----------------------------------------
5. 完成后
----------------------------------------
/opt/qtenv/qt-4.8.6-arm$ ls
bin  demos  examples  include  lib  mkspecs  plugins  translations
bin 目录下有qmake 文件
demos, examples 是示例文件
include 是qt项目需要的头文件
lib  包含有生成的so文件, 如
libQtCore.so  libQtGui.so  libQtNetwork.so  libQtSql.so  libQtTest.so  libQtXml.so
mkspecs 是编译工具选项,使用时不关心了
plugins. 有额外的so文件,例如:
sqldrivers/libqsqlite.so
imageformats/libqjpeg.so
translations 目录有各国语言翻译文件.qm
上面的这些文件就可以用到imx283 平台上了。
开源qt 代码就是这样编译的。 了解了qt 都生成了哪些文件。

EasyARM-iMX283 套件已经内建qt4.8.0 的支持,如果功能够用可以不用自己编译qt.

猜你喜欢

转载自blog.csdn.net/xufandecsdn/article/details/79815614