Open zouyalong-coder opened 1 year ago
error adding symbols: File in wrong format
This linker error is often caused by attempting to link together artifacts compiled for different architectures. From your description of what works and what doesn't, it sounds like your dynamic build for mipsel is trying to link in a mixture of mipsel and x86_64 objects.
If you cross-compile you need a linker capable of linking binaries for the target. In your case you seem to use the default host compiler which on macOS is incapable of linking ELF binaries and on x86_64 Ubuntu only capable of linking x86_64 binaries. In general you should get a cross-compilation C toolchain capable of producing binaries for the target and then point rustc to the gcc or clang inside it as linker. For musl specifically you may however be able to away with -Clink-arg=-fuse-ld=lld
if you have the lld linker installed as rustc comes bundled with a precompiled musl libc and knows how to point the linker to it.
Hello, I've written a simple Rust library and compiled it for several targets. I found that it compiles successfully on x86_64-unknown-linux-gnu and x86_64-apple-darwin, both as dynamic and static libraries. However, when targeting mipsel-unknown-linux-musl, only the static library compiles successfully. When attempting to compile a dynamic library, I encountered different issues on macOS and Ubuntu.
On macOS, the error is:
On ubuntu, the error is:
I expected to see this happen: shared library can be built
Meta
macos:
rustc --version --verbose
:ubuntu
rustc --version --verbose
:Backtrace
```
```