Difference between revisions of "APITestPage/zh"

From FriendlyELEC WiKi
Jump to: navigation, search
Line 1: Line 1:
===Setup Development Environment===
+
===搭建编译环境===
====Using Docker to Cross-Compile====
+
====使用Docker进行交叉编译====
Please refre to [https://github.com/friendlyarm/docker-cross-compiler-novnc docker-cross-compiler-novnc]
+
请参考 [https://github.com/friendlyarm/docker-cross-compiler-novnc docker-cross-compiler-novnc]
====Build a cross-compiling environment====
+
====本地搭建交叉编译环境====
=====Install required packages=====
+
=====安装编译所需软件包=====
Install and run requirements ubuntu 20.04, install required packages using the following commands:
+
建议使用'''64位'''的[http://mirrors.aliyun.com/ubuntu-releases/20.04/ Ubuntu 20.04系统],参考如下内容安装编译及打包所需要的软件包:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo apt-get -y update
 
sudo apt-get -y update
Line 11: Line 11:
 
   "$(curl -fsSL https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh)"
 
   "$(curl -fsSL https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh)"
 
</syntaxhighlight>
 
</syntaxhighlight>
The following cross-compilers will be installed:
+
你的电脑上会安装好如下交叉编译器:
 
{| class="wikitable"  
 
{| class="wikitable"  
 
|-
 
|-
! Version
+
! 版本
! Architecture
+
! 架构
! Compiler path
+
! 编译器路径
! Purpose
+
! 用途
 
|-
 
|-
 
| 4.9.3
 
| 4.9.3
 
| armhf
 
| armhf
 
| /opt/FriendlyARM/toolchain/4.9.3
 
| /opt/FriendlyARM/toolchain/4.9.3
| Can be used to build 32-bit ARM applications
+
| 用于编译32位的arm应用程序
 
|-
 
|-
 
| 6.4
 
| 6.4
 
| aarch64
 
| aarch64
 
| /opt/FriendlyARM/toolchain/6.4-aarch64
 
| /opt/FriendlyARM/toolchain/6.4-aarch64
| Can be used to build kernel 4.4
+
| 用于交叉编译4.4内核
 
|-
 
|-
 
| 11.3
 
| 11.3
 
| aarch64
 
| aarch64
 
| /opt/FriendlyARM/toolchain/11.3-aarch64
 
| /opt/FriendlyARM/toolchain/11.3-aarch64
| Can be used to build kernel 4.19 and above (including 5.10, 5.15) and U-Boot
+
| 用于交叉编译4.19及以上内核(含5.10,5.15)及uboot
 
|}
 
|}
=====Setting the compiler path=====
+
=====设置交叉编译器=====
Based on the table in the previous section, select the appropriate version of the compiler and add the compiler's path to PATH. For example, if you want to use the 11.3 cross-compiler, edit ~/.bashrc using vi and add the following content to the end:
+
参考上一节的表格,选用合适版本的编译器,然后将编译器的路径加入到PATH中,例加要使用11.3的交叉编译器,用vi编辑~/.bashrc,在末尾加入以下内容:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin:$PATH
 
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin:$PATH
 
export GCC_COLORS=auto
 
export GCC_COLORS=auto
 
</syntaxhighlight>
 
</syntaxhighlight>
Run the ~/.bashrc script to make it effective in the current commandline. Note: there is a space after ".":
+
执行一下~/.bashrc脚本让设置立即在当前shell窗口中生效,注意"."后面有个空格:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
. ~/.bashrc
 
. ~/.bashrc
 
</syntaxhighlight>
 
</syntaxhighlight>
To verify if the installation was successful:
+
验证是否安装成功:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ aarch64-linux-gcc -v
 
$ aarch64-linux-gcc -v

Revision as of 04:55, 8 April 2023

1 搭建编译环境

1.1 使用Docker进行交叉编译

请参考 docker-cross-compiler-novnc

1.2 本地搭建交叉编译环境

1.2.1 安装编译所需软件包

建议使用64位Ubuntu 20.04系统,参考如下内容安装编译及打包所需要的软件包:

sudo apt-get -y update
sudo apt-get install -y sudo curl
sudo bash -c \
  "$(curl -fsSL https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh)"

你的电脑上会安装好如下交叉编译器:

版本 架构 编译器路径 用途
4.9.3 armhf /opt/FriendlyARM/toolchain/4.9.3 用于编译32位的arm应用程序
6.4 aarch64 /opt/FriendlyARM/toolchain/6.4-aarch64 用于交叉编译4.4内核
11.3 aarch64 /opt/FriendlyARM/toolchain/11.3-aarch64 用于交叉编译4.19及以上内核(含5.10,5.15)及uboot
1.2.2 设置交叉编译器

参考上一节的表格,选用合适版本的编译器,然后将编译器的路径加入到PATH中,例加要使用11.3的交叉编译器,用vi编辑~/.bashrc,在末尾加入以下内容:

export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin:$PATH
export GCC_COLORS=auto

执行一下~/.bashrc脚本让设置立即在当前shell窗口中生效,注意"."后面有个空格:

. ~/.bashrc

验证是否安装成功:

$ aarch64-linux-gcc -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gcc
COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolchain/11.3-aarch64/libexec/gcc/aarch64-cortexa53-linux-gnu/11.3.0/lto-wrapper
Target: aarch64-cortexa53-linux-gnu
Configured with: /home/cross/arm64/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/11.3-aarch64 --exec_prefix=/opt/FriendlyARM/toolchain/11.3-aarch64 --with-sysroot=/opt/FriendlyARM/toolchain/11.3-aarch64/aarch64-cortexa53-linux-gnu/sysroot --enable-languages=c,c++ --enable-fix-cortex-a53-843419 --with-arch=armv8-a+crypto+crc --with-cpu=cortex-a53 --with-pkgversion=ctng-1.25.0-119g-FA --with-bugurl=http://www.friendlyelec.com/ --enable-objc-gc --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --disable-libmpx --with-gmp=/home/cross/arm64/buildtools --with-mpfr=/home/cross/arm64/buildtools --with-mpc=/home/cross/arm64/buildtools --with-isl=/home/cross/arm64/buildtools --enable-lto --enable-threads=posix --disable-libstdcxx-pch --enable-clocale=gnu --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-indirect-function --enable-gnu-unique-object --enable-default-pie --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-gold --with-libintl-prefix=/home/cross/arm64/buildtools --disable-multilib --with-local-prefix=/opt/FriendlyARM/toolchain/11.3-aarch64/aarch64-cortexa53-linux-gnu/sysroot --enable-long-long --enable-checking=release --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.3.0 (ctng-1.25.0-119g-FA)