[在 Linux 上构建 Windows 程序]
Rust 为构建 Windows 程序提供了两种不同的工具链:
- [MSVC]:在 Windows 上构建程序时默认的工具链,需要下载微软的 SDK。
- [GNU]:基于
MINGW
的替代构建方式,可能设置起来更容易
[首次设置 MSVC]
[Rust MSVC 工具链]
实际上,你可以在 Linux 上使用相同的基于 MSVC 的 Rust 工具链,这也是在 Windows 构建程序时使用的方案。
将需要支持的目标平台添加到你的 Rust 安装库中(假设你使用了 rustup
):
rustup target add x86_64-pc-windows-msvc
这就安装了 Rust 为 Windows 编译程序所需的文件,包括 Rust 标准库。
[Microsoft Windows SDKs]
你需要安装微软的 Windows SDK,就像在 Windows 上工作时一样。在 Linux 上,这可以通过一个叫做 xwin
的简单脚本来完成。你需要接受微软的专利许可。
安装 xwin
:
cargo install xwin
现在,使用 xwin
接受微软的许可,从微软服务器下载所有文件,并将它们安装到你选择的目录中。
例如,假设要安装到 /opt/xwin/
: 建议使用/home/$USER/.xwin
xwin --accept-license splat --output /home/$USER/.xwin
[链接 (MSVC)]
Rust 需要知道如何链接最终的 EXE 文件。
默认的微软链接器(link.exe
)在 Linux 上是不可用的。相反,我们需要使用 LLD 链接器(无论如何,在 Windows 上工作时也推荐使用这个)。只要在你的 Linux 发行版中安装 lld
包就可以了。
sudo apt install lld
我们还需要告诉 Rust 微软 Windows SDK 库的位置中与 xwin
一起安装时指定的位置)。
把这个添加到 .cargo/config.toml
中(位于你的主文件夹或你的 bevy 项目中)。
注意:要在项目里面创建这个文件 https://doc.rust-lang.org/cargo/reference/config.html
[target.x86_64-pc-windows-msvc]
linker = "lld"
rustflags = [
"-Lnative=/home/landv/.xwin/crt/lib/x86_64",
"-Lnative=/home/landv/.xwin/sdk/lib/um/x86_64",
"-Lnative=/home/landv/.xwin/sdk/lib/ucrt/x86_64"
]
[首次设置 GNU]
[Rust GNU 工具链]
你也可以使用其他基于 GNU 的 Windows 工具链。
将需要支持的目标平台添加到你的 Rust 安装中(假设你使用 rustup
)。
rustup target add x86_64-pc-windows-gnu
这就安装了 Rust 为 Windows 编译程序所需的文件,包括 Rust 标准库。
[MINGW]
GNU 工具链需要安装 MINGW 环境,你的发行版可能为它提供了一个软件包。在你的发行版中搜索一个交叉编译的 MINGW 软件包。
它可能被称为:cross-x86_64-w64-mingw32,但这在不同的发行版中会有所不同。
你不需要来自微软的任何文件。
[构建你的项目]
最终,在完成所有的设置后,你就可以为 Windows 构建你的 Rust项目了。
cargo build --target=x86_64-pc-windows-msvc --release
cargo build --target=x86_64-pc-windows-gnu --release
wine
字体和主题
https://linux.zone/362
sudo apt install winetricks
-
deepin-wine6-stable 改名为wine
-
cp cat /usr/bin/deepin-wine6-stable /usr/bin/wine
-
#修改这里 name=$(basename $0) name="deepin-wine6-stable"
-