ubuntu20.04 从零到rust交叉编译环境搭建

//如果写成脚本需要加-y参数
sudo apt update
sudo apt install curl
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh(选默认1)
source $HOME/.cargo/env

//安装依赖包
sudo apt install -y openssl libssl-dev libudev-dev cmake llvm clang musl-tools build-essential

//设置软链接
sudo ln -s /usr/bin/g++ /usr/bin/musl-g++

//添加target
rustup target add x86_64-pc-windows-gnu
rustup target add x86_64-unknown-linux-musl
//命令
//linux
cargo build --release --target=x86_64-unknown-linux-musl
//win
cargo build --release --target=x86_64-pc-windows-gnu

你可能感兴趣的:(rust,rust)