|
|
Line 1: |
Line 1: |
− | ===PC上安装Qt-Embedded=== | + | ==交叉编译你的Qt应用程序 == |
| | | |
− | Ubuntu Core的文件系统中包含了完整的Qt-Embedded二进制包,我们只需要复制到电脑上即可使用。<br />
| + | ===S5P4418平台的编译=== |
− | <br />
| + | |
− | 方法是,先制作一张 Ubuntu Core with Qt-Embedded 系统的SD卡,此时 SD 卡一般有两个分区,第二个分区是Ubuntu core系统的根分区,
| + | |
− | 将这个分区挂载到某个目录,假设挂载到 /media/root/rootfs, 用以下命令安装:
| + | |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
− | # sudo mkdir -p /usr/local/Trolltech
| + | git clone https://github.com/friendlyarm/QtE-Demo |
| + | mkdir build && cd build |
| + | /usr/local/Trolltech/Qt-5.9.1-nexell32/bin/qmake ../QtE-Demo/QtE-Demo.pro |
| + | make |
| </syntaxhighlight> | | </syntaxhighlight> |
− | 如果是32位的文件系统,复制以下目录:
| + | ===S5P6818平台的编译=== |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
− | # sudo cp -af /media/root/rootfs/usr/local/Trolltech/QtEmbedded-5.9.1-arm /usr/local/Trolltech/
| + | git clone https://github.com/friendlyarm/QtE-Demo |
| + | mkdir build && cd build |
| + | /usr/local/Trolltech/Qt-5.9.1-nexell64/bin/qmake ../QtE-Demo/QtE-Demo.pro |
| + | make |
| </syntaxhighlight> | | </syntaxhighlight> |
− | 如果是64位的文件系统,复制以下目录:
| + | ===Allwinner H3平台的编译=== |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
− | # sudo cp -af /media/root/rootfs/usr/local/Trolltech/QtEmbedded-5.9.1-arch64 /usr/local/Trolltech/
| + | export PATH=/opt/FriendlyARM/toolschain/4.9.3/bin/:$PATH |
| + | git clone https://github.com/friendlyarm/QtE-Demo |
| + | mkdir build && cd build |
| + | /usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake ../QtE-Demo/QtE-Demo-Qt4.pro |
| + | make |
| </syntaxhighlight> | | </syntaxhighlight> |
− | | + | ===Allwinner H5平台的编译=== |
− | ===PC上安装交叉编译器=== | + | |
− | 和 Qt-Embedded 分 32位 和 64位 一样,编译器也有两个版本,分别对应的是 32位 和 64位 的 Ubuntu core系统。<br />
| + | |
− | 可以用以下命令查看Ubuntu core系统是否是64位:
| + | |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
− | $ sudo uname --m
| + | export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH |
− | aarch64
| + | git clone https://github.com/friendlyarm/QtE-Demo |
− | </syntaxhighlight>
| + | mkdir build && cd build |
− | 也可以简单以文件系统的 Qt-Embedded 的目录名区分,其中: <br />
| + | /usr/local/Trolltech/QtEmbedded-4.8.6-arm-a64/bin/qmake ../QtE-Demo/QtE-Demo-Qt4.pro |
− | QtEmbedded-5.9.1-arm: 是使用 gcc 4.9.3 的 32位编译器编译的 (arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz);<br />
| + | |
− | QtEmbedded-5.9.1-arch64: 是使用 gcc 6.4 的 64位编译器编译的 (aarch64-cortexa53-linux-gnu-6.4.tar.xz);<br />
| + | |
− | | + | |
− | ====32位交叉编译器(S5P4418/S5P6818/Allwinner H3平台)====
| + | |
− | | + | |
− | 下载并解压编译器:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | git clone https://github.com/friendlyarm/prebuilts.git
| + | |
− | sudo mkdir -p /opt/FriendlyARM/toolchain
| + | |
− | sudo tar xf prebuilts/gcc-x64/arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz -C /opt/FriendlyARM/toolchain/
| + | |
− | </syntaxhighlight>
| + | |
− | | + | |
− | 然后将编译器的路径加入到PATH中,用vi编辑vi ~/.bashrc,在末尾加入以下内容:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH | + | |
− | export GCC_COLORS=auto
| + | |
− | </syntaxhighlight>
| + | |
− | | + | |
− | 执行一下~/.bashrc脚本让设置立即在当前shell窗口中生效,注意"."后面有个空格:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | . ~/.bashrc
| + | |
− | </syntaxhighlight>
| + | |
− | | + | |
− | 安装完成后,你可以快速的验证是否安装成功:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | arm-linux-gcc -v
| + | |
− | Using built-in specs.
| + | |
− | COLLECT_GCC=arm-linux-gcc
| + | |
− | COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolchain/4.9.3/libexec/gcc/arm-cortexa9-linux-gnueabihf/4.9.3/lto-wrapper
| + | |
− | Target: arm-cortexa9-linux-gnueabihf
| + | |
− | Configured with: /work/toolchain/build/src/gcc-4.9.3/configure --build=x86_64-build_pc-linux-gnu
| + | |
− | --host=x86_64-build_pc-linux-gnu --target=arm-cortexa9-linux-gnueabihf --prefix=/opt/FriendlyARM/toolchain/4.9.3
| + | |
− | --with-sysroot=/opt/FriendlyARM/toolchain/4.9.3/arm-cortexa9-linux-gnueabihf/sys-root --enable-languages=c,c++
| + | |
− | --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3 --with-float=hard
| + | |
− | ...
| + | |
− | Thread model: posix
| + | |
− | gcc version 4.9.3 (ctng-1.21.0-229g-FA)
| + | |
− | </syntaxhighlight>
| + | |
− | | + | |
− | ====64位交叉编译器(Amlogic S905/S5P6818/Allwinner H5平台)====
| + | |
− | | + | |
− | 首先下载并解压编译器:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | git clone https://github.com/friendlyarm/prebuilts.git
| + | |
− | sudo mkdir -p /opt/FriendlyARM/toolchain
| + | |
− | sudo tar xf prebuilts/gcc-x64/aarch64-cortexa53-linux-gnu-6.4.tar.xz -C /opt/FriendlyARM/toolchain/
| + | |
− | </syntaxhighlight>
| + | |
− | | + | |
− | 然后将编译器的路径加入到PATH中,用vi编辑vi ~/.bashrc,在末尾加入以下内容:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin:$PATH
| + | |
− | export GCC_COLORS=auto
| + | |
− | </syntaxhighlight>
| + | |
− | | + | |
− | 执行一下~/.bashrc脚本让设置立即在当前shell窗口中生效,注意"."后面有个空格:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | . ~/.bashrc
| + | |
− | </syntaxhighlight>
| + | |
− | | + | |
− | 安装完成后,你可以快速的验证是否安装成功:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | # aarch64-linux-gcc -v
| + | |
− | Using built-in specs.
| + | |
− | COLLECT_GCC=aarch64-linux-gcc
| + | |
− | COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolchain/6.4-aarch64/libexec/gcc/aarch64-cortexa53-linux-gnu/6.4.0/lto-wrapper
| + | |
− | Target: aarch64-cortexa53-linux-gnu
| + | |
− | Configured with: /work/toolchain/build/aarch64-cortexa53-linux-gnu/build/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=aarch64-cortexa53-linux-gnu --prefix=/opt/FriendlyARM/toolchain/6.4-aarch64 --with-sysroot=/opt/FriendlyARM/toolchain/6.4-aarch64/aarch64-cortexa53-linux-gnu/sysroot --enable-languages=c,c++ --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-cpu=cortex-a53 --with-pkgversion=ctng-1.23.0-150g-FA --with-bugurl=http://www.friendlyarm.com/ --enable-objc-gc --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --disable-libmpx --with-gmp=/work/toolchain/build/aarch64-cortexa53-linux-gnu/buildtools --with-mpfr=/work/toolchain/build/aarch64-cortexa53-linux-gnu/buildtools --with-mpc=/work/toolchain/build/aarch64-cortexa53-linux-gnu/buildtools --with-isl=/work/toolchain/build/aarch64-cortexa53-linux-gnu/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --disable-libstdcxx-pch --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-indirect-function --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-gold --with-libintl-prefix=/work/toolchain/build/aarch64-cortexa53-linux-gnu/buildtools --disable-multilib --with-local-prefix=/opt/FriendlyARM/toolchain/6.4-aarch64/aarch64-cortexa53-linux-gnu/sysroot --enable-long-long --enable-checking=release
| + | |
− | Thread model: posix
| + | |
− | gcc version 6.4.0 (ctng-1.23.0-150g-FA)
| + | |
− | </syntaxhighlight>
| + | |
− | | + | |
− | ===编写并运行Qt版本的示例程序===
| + | |
− | | + | |
− | 在PC上下载示例源代码, 然后创建一个 build目录:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | cd ~
| + | |
− | git clone https://github.com/friendlyarm/QtE-Demo.git | + | |
− | mkdir ~/build-qte-demo | + | |
− | cd ~/build-qte-demo | + | |
− | </syntaxhighlight>
| + | |
− | <br />
| + | |
− | 针对32位系统的编译步骤:
| + | |
− | <syntaxhighlight lang="bash">
| + | |
− | /usr/local/Trolltech/QtEmbedded-5.9.1-arm/bin/qmake ~/QtE-Demo | + | |
− | export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin/:$PATH
| + | |
| make | | make |
| </syntaxhighlight> | | </syntaxhighlight> |
− | <br />
| + | ===Amlogic S905平台的编译=== |
− | 针对64位系统的编译步骤:
| + | |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
− | /usr/local/Trolltech/QtEmbedded-5.9.1-arch64/bin/qmake ~/QtE-Demo | + | export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH |
− | export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
| + | git clone https://github.com/friendlyarm/QtE-Demo |
| + | mkdir build && cd build |
| + | /usr/local/Trolltech/QtEmbedded-5.9.1-arch64/bin/qmake ../QtE-Demo/QtE-Demo.pro |
| make | | make |
− | </syntaxhighlight>
| |
− |
| |
− | 编译成功后,会得到了 QtE-Demo 的二进制文件,将它上传到开发板后,在串口终端用以下命令运行:
| |
− | <syntaxhighlight lang="bash">
| |
− | . setqt5env
| |
− | QtE-Demo -qws&
| |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/Qt-5.9.1-nexell32/bin/qmake ../QtE-Demo/QtE-Demo.pro
make
git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/Qt-5.9.1-nexell64/bin/qmake ../QtE-Demo/QtE-Demo.pro
make
export PATH=/opt/FriendlyARM/toolschain/4.9.3/bin/:$PATH
git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake ../QtE-Demo/QtE-Demo-Qt4.pro
make
export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/QtEmbedded-4.8.6-arm-a64/bin/qmake ../QtE-Demo/QtE-Demo-Qt4.pro
make
export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/QtEmbedded-5.9.1-arch64/bin/qmake ../QtE-Demo/QtE-Demo.pro
make
. /usr/bin/setqt5env
/root/QtE-Demo -qws&