wsl --set-default-version 2
wsl --update
cargo install cross
docker ps -a
cross build --release --target x86_64-unknown-linux-musl
toolchain 'stable-x86_64-unknown-linux-gnu' may not be able to run on this system
note: to build software for that platform, try `rustup target add x86_64-unknown-linux-gnu` instead
note: add the `--force-non-host` flag to install the toolchain anyway
Error:
0: couldn't install toolchain `stable-x86_64-unknown-linux-gnu`
1: `rustup toolchain add stable-x86_64-unknown-linux-gnu --profile minimal` failed with exit code: 1
提示我们stable-x86_64-unknown-linux-gnu可能无法在此系统上运行
我们按照提示强制安装相关工具链
rustup toolchain add stable-x86_64-unknown-linux-gnu --profile minimal --force-non-host
安装成功后,再次运行:
cross build --release --target x86_64-unknown-linux-musl
即可交叉编译成功