🎃

windows-rs を WSL2 (Ubuntu) でビルド&実行する

2022/10/17に公開

特に躓くこともなく普通にビルドと実行ができたので、手順をメモ。
試した windows-rs のバージョンは 0.42.0。

準備:

$ sudo apt install gcc-mingw-w64-x86-64
$ rustup target add x86_64-pc-windows-gnu

リポジトリを clone してサンプルを実行:

$ git clone https://github.com/microsoft/windows-rs.git
$ cd windows-rs/crates/samples/create_window
$ cargo run --target=x86_64-pc-windows-gnu
...
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `/path/to/windows-rs/target/x86_64-pc-windows-gnu/debug/sample_create_window.exe`
WM_PAINT
WM_DESTROY

表示されたウィンドウ:

Discussion