目前,Rust的交叉编译故事是scattered across several outdated博客文章,repos,工具(musl,crosstools-ng)或Docker文件 .
我花了大约20个小时努力让ARM和Windows编译和链接为一个不需要libc的项目工作,所以我很乐意看到完整的规范指令来获得“Hello world!”为以下目标编译的示例:
-
OSX到ARM,
armv7-unknown-linux-gnueabihf
-
Linux到Windows,
x86_64-pc-windows-msvc
和x86_64-pc-windows-gnu
-
Windows到Linux,
gcc-arm-linux-gnueabihf
-
Windows到ARM,
gcc-arm-linux-gnueabihf
这是一个simple TCP server,我无法在OSX上为Windows或ARM链接,尽管安装了我可以发现的每个依赖项 .
特别:
-
对于Windows~-msvc,它会抛出
error: linker link.exe not found
. 我缺少哪种VC依赖? -
对于Windows~ -gnu,它会在安装了最新的XCode clang的情况下抛出
clang: error: linker command failed with exit code 1
.gcc -v
显示Apple LLVM version 10.0.0 (clang-1000.11.45.5)
. -
对于ARM,
rustup toolchain install armv7-unknown-linux-gnueabihf
抛出error: no candidate toolchains found. error: toolchain 'armv7-unknown-linux-gnueabihf' is not installed
.