cross
という有名なツールがあるが、動作に DockerかPodmanが必要なので使いたくない方向け。
mingw-w64をインストール
brew install mingw-w64
プロジェクトルートにconfig.toml
を作成し、以下の内容を追加。
[target.x86_64-pc-windows-gnu]linker = "x86_64-w64-mingw32-gcc"ar = "x86_64-w64-mingw32-ar"
コンパイル
cargo build --target x86_64-pc-windows-gnu