Difference between revisions of "Template:HowToBuildQtApplicationAllwinner/zh"

From FriendlyELEC WiKi
Jump to: navigation, search
(Created page with "===PC上安装Qt-Embedded=== Ubuntu Core的文件系统中包含了完整的Qt-Embedded二进制包,我们只需要复制到电脑上即可使用。<br /> <br /> 方法是...")
 
(Blanked the page)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
===PC上安装Qt-Embedded===
 
  
Ubuntu Core的文件系统中包含了完整的Qt-Embedded二进制包,我们只需要复制到电脑上即可使用。<br />
 
<br />
 
方法是,先制作一张 Ubuntu Core with Qt-Embedded 系统的SD卡,此时 SD 卡一般有两个分区,第二个分区是Ubuntu core系统的根分区,
 
将这个分区挂载到某个目录,假设挂载到 /media/root/rootfs, 用以下命令安装:
 
<syntaxhighlight lang="bash">
 
# sudo mkdir -p /usr/local/Trolltech
 
</syntaxhighlight>
 
如果是32位的文件系统,复制以下目录:
 
<syntaxhighlight lang="bash">
 
# sudo cp -af /media/root/rootfs/usr/local/Trolltech/QtEmbedded-5.9.1-arm /usr/local/Trolltech/
 
</syntaxhighlight>
 
如果是64位的文件系统,复制以下目录:
 
<syntaxhighlight lang="bash">
 
# sudo cp -af /media/root/rootfs/usr/local/Trolltech/QtEmbedded-5.9.1-arch64 /usr/local/Trolltech/
 
</syntaxhighlight>
 
 
===PC上安装交叉编译器===
 
和 Qt-Embedded 分 32位 和 64位 一样,编译器也有两个版本,分别对应的是 32位 和 64位 的 Ubuntu core系统。<br />
 
可以用以下命令查看Ubuntu core系统是否是64位:
 
<syntaxhighlight lang="bash">
 
$ sudo uname --m
 
aarch64
 
</syntaxhighlight>
 
也可以简单以文件系统的 Qt-Embedded 的目录名区分,其中: <br />
 
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
 
</syntaxhighlight>
 
<br />
 
针对64位系统的编译步骤:
 
<syntaxhighlight lang="bash">
 
/usr/local/Trolltech/QtEmbedded-5.9.1-arch64/bin/qmake ~/QtE-Demo
 
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
 
make
 
</syntaxhighlight>
 
 
编译成功后,会得到了 QtE-Demo 的二进制文件,将它上传到开发板后,在串口终端用以下命令运行:
 
<syntaxhighlight lang="bash">
 
. setqt5env
 
QtE-Demo -qws&
 
</syntaxhighlight>
 
 
===开机自动运行Qt程序===
 
 
以运行上一章节中的 QtE-Demo 程序为例,假设它放在 /root 目录,则你可以编辑 /etc/rc.local 文件,确否有以下内容:
 
<syntaxhighlight lang="bash">
 
. /usr/bin/setqt5env
 
/root/QtE-Demo -qws&
 
</syntaxhighlight>
 

Latest revision as of 10:06, 1 December 2017