主机环境:Ubuntu 12.04, 64位 。
交叉编译工具:Poky 1.5.3 交叉编译工具链及相关工具
1、安装交叉编译工具
将 poky 交叉编译工具压缩包解压到 /opt 目录。
$ sudo cp fsl-imx-x11-Yocto_1.5.3.tar.bz2 /opt
$ cd /opt
$ sudo tar jxvf fsl-imx-x11-Yocto_1.5.3.tar.bz2
用 ls 命令查看一下。
$ ls -1 /opt/poky/1.5.3/
environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
site-config-cortexa9hf-vfp-neon-poky-linux-gnueabi
sysroots
version-cortexa9hf-vfp-neon-poky-linux-gnueabi
为交叉编译工具指定用户或组,XXX 是你的 ubuntu 用户的名字。
$ sudo chown -R XXX:XXX /opt/poky
2、安装 Qt Creator
我这里下载到的是 qt-creator-opensource-linux-x86_64-3.2.1.run,安装过程如下。
同样,拷贝到 /opt 目录下,直接运行即可进入安装界面。
$ sudo cp qt-creator-opensource-linux-x86_64-3.2.1.run /opt
$ cd /opt
$ ./qt-creator-opensource-linux-x86_64-3.2.1.run






3、配置 Qt creator 的运行环境
修改 /opt/qtcreator-3.2.1/bin/qtcreator.sh,在文件的第一行加入一段:
. /opt/poky/1.5.3/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi

environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi 的内容如下。
export PATH=/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin:/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi:$PATH
export PKG_CONFIG_SYSROOT_DIR=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
export PKG_CONFIG_PATH=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/lib/pkgconfig
export CONFIG_SITE=/opt/poky/1.5.3/site-config-cortexa9hf-vfp-neon-poky-linux-gnueabi
export CC="arm-poky-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi"
export CXX="arm-poky-linux-gnueabi-g++ -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi"
export CPP="arm-poky-linux-gnueabi-gcc -E -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi"
export AS="arm-poky-linux-gnueabi-as "
export LD="arm-poky-linux-gnueabi-ld --sysroot=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi"
export GDB=arm-poky-linux-gnueabi-gdb
export STRIP=arm-poky-linux-gnueabi-strip
export RANLIB=arm-poky-linux-gnueabi-ranlib
export OBJCOPY=arm-poky-linux-gnueabi-objcopy
export OBJDUMP=arm-poky-linux-gnueabi-objdump
export AR=arm-poky-linux-gnueabi-ar
export NM=arm-poky-linux-gnueabi-nm
export M4=m4
export TARGET_PREFIX=arm-poky-linux-gnueabi-
export CONFIGURE_FLAGS="--target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi"
export CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types"
export CXXFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types -fpermissive"
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"
export CPPFLAGS=""
export OECORE_NATIVE_SYSROOT="/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux"
export OECORE_TARGET_SYSROOT="/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi"
export OECORE_ACLOCAL_OPTS="-I /opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/share/aclocal"
export OECORE_DISTRO_VERSION="1.5.3"
export OECORE_SDK_VERSION="1.5.3"
export PYTHONHOME=/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr
export ARCH=arm
export CROSS_COMPILE=arm-poky-linux-gnueabi-
export OE_QMAKE_CFLAGS="$CFLAGS"
export OE_QMAKE_CXXFLAGS="$CXXFLAGS"
export OE_QMAKE_LDFLAGS="$LDFLAGS"
export OE_QMAKE_CC=$CC
export OE_QMAKE_CXX=$CXX
export OE_QMAKE_LINK=$CXX
export OE_QMAKE_AR=$AR
export OE_QMAKE_LIBDIR_QT=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi//usr/lib
export OE_QMAKE_INCDIR_QT=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi//usr/include/qt4
export OE_QMAKE_MOC=/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/moc4
export OE_QMAKE_UIC=/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/uic4
export OE_QMAKE_UIC3=/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/uic34
export OE_QMAKE_RCC=/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/rcc4
export OE_QMAKE_QDBUSCPP2XML=/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/qdbuscpp2xml4
export OE_QMAKE_QDBUSXML2CPP=/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/qdbusxml2cpp4
export OE_QMAKE_QT_CONFIG=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi//usr/share/qt4/mkspecs/qconfig.pri
export QMAKESPEC=/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi//usr/share/qt4/mkspecs/linux-g++
export QT_CONF_PATH=/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux//etc/qt.conf
4、配置 Qt creator
4.1 运行 QT creator
进入到 /opt/qtcreator-3.2.1/bin 目录,执行命令 $ ./ qtcreator.sh
,运行 Qt creator。

然后,在 Qt 运行界面下,菜单栏点击 “Tools –> Options –> Build&Run”,进行相关配置。

4.2 设置 “Compiler”
添加一个“ Manual” ,点击 Add –> GCC ,添加一个 GCC。

点击 Browser 选择 Compiler path 为:/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++
,然后点击 apply。
4.3 设置 “QT Versions”
添加一个“ Manual” ,点击 Add ,点击 Browser,选择 qmake location 为:/opt/poky/1.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/qmake
,然后点击 apply。

4.4 设置“ Kit”
添加一个“ Manual” ,点击 Add,点击 Browser,选择 Sysroot 为:/opt/poky/1.5.3/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
。点击 Compiler,选择先去配置好的 GCC。
然后点击 apply。

最后点击 OK 退出。
至此,i.MX 平台的 Qt 开发环境搭建完毕,接下来就可以在此环境上面进行 Qt 的应用开发了!