-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Cannot cross-compile rust crate for macOS #180
Comments
|
I get the same error when cross-compiling |
So I've hit the same problem compiling my tool that depends on The problem (at least for me) seems to be that the crate uses the wrong C compiler, namely Assuming that you are using
After doing all this it now builds. (It works for both Linux-GNU, Linux-Musl, Android, Darwin, both x86_64 and aarch64.) |
You need to use cargo-zigbuild to cross-compile Rust code that includes C code: cargo zigbuild --target=x86_64-apple-darwin |
@jedisct1 wow that is wonderful. The complete pair of commands I just used to do a cross-compile was:
|
When targeting Linux, the command (actually Zig) also allows choosing a glibc version that may differ from the one installed on the system. This is very useful to build redistributable binaries that work everywhere, even on CentOS 5. |
Everything goes fine when I try to build the crate for GNU/Linux, Windows or even Android but when I set
x86_64-apple-darwin
as the target, I get the following error:The text was updated successfully, but these errors were encountered: