Skip to content

Instantly share code, notes, and snippets.

@Scoubi
Last active February 7, 2024 18:34
Show Gist options
  • Save Scoubi/20b99c424e446227cb07c5da5b4a3ad4 to your computer and use it in GitHub Desktop.
Save Scoubi/20b99c424e446227cb07c5da5b4a3ad4 to your computer and use it in GitHub Desktop.
Cross Compile Rust Banaries from Mac OSX (M1)
1. brew install SergioBenitez/osxct/x86_64-unknown-linux-gnu
1. brew install x86_64-linux-gnu-binutils
1. rustup target add x86_64-unknown-linux-gnu
1. Edit ~/.cargo/config and add
```
[target.x86_64-unknown-linux-gnu]
linker = "x86_64-unknown-linux-gnu-gcc"
```
1. source ~/.cargo/config
1. Edit Cargo.toml and include OpenSSL crate dependency **This is the part missing from many how-to**
```
[dependencies]
openssl = { version = "0.10", features = ["vendored"] }
```
cargo build --target x86_64-unknown-linux-gnu --release
1. brew install mingw-w64
1. I think I needed to install cmake
`brew install cmake`
1. Edit ~/.cargo/config and add
```
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
```
1. source ~/.cargo/config
cargo build --target=x86_64-pc-windows-gnu --release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment