I want to cross compile target for aarch64-unknown-linux-gnu on my Windows. I added following lines in .corgo/config.toml. When I build with cargo build --target=aarch64-unknown-linux-gnu --release, I got errors:
rust-lld: error: unable to find library -lgcc_s
rust-lld: error: unable to find library -lutil
rust-lld: error: unable to find library -lrt
rust-lld: error: unable to find library -lpthread
rust-lld: error: unable to find library -lm
rust-lld: error: unable to find library -ldl
rust-lld: error: unable to find library -lc
Using just lld as linker is not enough. To compile for linux you need the gcc or clang wrapper around the linker to tell the linker which libraries it needs to link against and where to find them. In addition you need libc locally. You could try getting a cross-compilation gcc that runs on windows and compiles to linux. You could also try using zig cc as linker: Zig Makes Rust Cross-compilation Just Work · Um, actually...
In my experience this works fine if you have run rustup target add [target-name] (which it looks like you have?) and you have no non-rust code to compile or native libraries to link, otherwise you're at the mercy of the native toolchain and the dependencies it has - I might be missing something here though!
This might be less of a problem in the mid to long term, as the raw-dylib RFC seems to be getting close, which as I understand it is the first of several steps to removing the need for import libraries to cross compile.
rustup target add aarch64-unknown-linux-gnu is not enough.
Cross compiling to linux on windows is not a good choice. just as bjorn3's reply, if you configure your system correctly, rust-lld will work well.
I also recommend to use zig cc as linker for cross-compilation. cargo-zigbuild is a crate which can compile cargo project with zig as linker for easier cross compiling.
libstd(of aarch64-unknown-linux-gnu) dynamicly link to libc. If you use cargo build --target x86_64-unknown-linux-musl(or maybe aarch64-unknown-linux-musl ?), it just works.
But performance of musl libc's malloc is poor, it's not suitable for high-load application.