Rust本身是支持跨平台编译的。看资料是只需要简单的跨平台编译命令就好了。
一、官方给出的资料是
rustup target add x86_64-unknown-linux-gnu
cargo build –release –target x86_64-unknown-linux-gnu
两条命令一出就 O 👌🏻了。然后到了我这里并非如此。问题是一波接着一波,像个解俄罗斯套娃一样。
二、找到 medium 上一个博主的回到。他是在 mul 和 gnu 的 Rust跨平台编译方式 上做了一个比较,然后取舍。
不过我都试了。并不能解决问题。
三、在 stackoverflow 上有一条相同的问题,是通过安装
brew install x86_64-unknown-linux-gnu
去尝试解决的,但是在我这里。一些莫名的报错,比如:
fatal: not in a git directory
Error: Command failed with exit 128: git
我明明实在 cargo new 创建的目录下的。这个不在 git 目录内,是莫名其妙,暂且不表。
四、后来找到github上的处理方式 macos-cross-toolchains
还是不行的
➜ chatgpt git:(main) ✗ brew install openssl@1.1
openssl@1.1 openssl@1.1 is already installed but outdated (so it will be upgraded).
==> Fetching dependencies for openssl@1.1 ==> Fetching dependencies for openssl@1.1: ca-certificates
==> Fetching ca-certificates
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/ca-certificates-2023-01-10.all.bottle.tar.gz
Already downloaded: /Users/c/Library/Caches/Homebrew/downloads/637587df586ffb04fbdb7243608f303e3e5f0da7c2d957ae45535261a60a6e7e–ca-certificates-2023-01-10.all.bottle.tar.gz
==> Fetching openssl@1.1
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl%401.1-1.1.1t.ventura.bottle.tar.gz
Already downloaded: /Users/c/Library/Caches/Homebrew/downloads/c32771c573f21242ce5120be535a7dac87a38f7a6d64fb9c61210e7156c30106– openssl@1.1-1.1.1t.ventura.bottle.tar.gz
==> Installing dependencies for <