1. 安装RUST环境
# 参见网址 https://www.rust-lang.org/tools/install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
选择1 默认安装即可
2. 修改cargo的config
文件
# 路径为 ~/.cargo/config vim ~/.cargo/config #添加下列文本 [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc"
3. 查看支持的目标平台
rustup target add aarch64-unknown-linux-gnu
rustup target list
aarch64-unknown-linux-gnu (installed)
x86_64-unknown-linux-gnu (installed)
apt-cache search aarch64
(base) wanhy@wanhy-ubuntu:~$ apt-cache search aarch64
cpp-7-aarch64-linux-gnu - GNU C preprocessor
cpp-aarch64-linux-gnu - GNU C preprocessor (cpp) for the arm64 architecture
g++-aarch64-linux-gnu - GNU C++ compiler for the arm64 architecture
gcc-7-aarch64-linux-gnu-base - GCC, the GNU Compiler Collection (base package)
gcc-aarch64-linux-gnu - GNU C compiler for the arm64 architecture
apt install g++-aarch64-linux-gnu
apt install gcc-aarch64-linux-gnu
4. 添加新工程
cargo new hello --bin cd hello/ cargo build cargo build --release cargo build --target=aarch64-unknown-linux-gnu --release