Skip to content

Windows

我们在以下 Windows 版本和架构上测试 Slint:

操作系统 架构
Windows 10 x86-64
Windows 11 x86-64, aarch64

运行应用程序时,默认会显示一个控制台窗口。

要禁用控制台,请将 WINDOWS 指定为子系统。

从命令行运行应用程序时,如果子系统设置为 WINDOWS,它将不再输出 stdout。如果你需要 stdout,可以考虑使用 FreeConsole()。

更多细节请参见 #3235。

将以下代码添加到包含 fn main() 的 .rs 文件顶部:

#![windows_subsystem = "windows"]
rust

如果你想在 debug 模式下保留控制台输出:

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
rust

在 Windows 上开发 Rust 应用程序时,你迟早可能会观察到程序以 STATUS_STACK_OVERFLOW 中止, 尤其是在 debug 构建中。这是一个已知问题,是栈空间需求高与 MSVC 默认给主线程设置的栈大小 相比其他操作系统明显更小共同造成的。

你可以通过配置链接器来解决。在你的项目中创建一个 .cargo\config.toml 文件(注意是 .cargo 子目录),内容如下:

[target.x86_64-pc-windows-msvc]
# Increase default stack size to avoid running out of stack
# space in debug builds. The size matches Linux's default.
rustflags = ["-C", "link-arg=/STACK:8000000"]
[target.aarch64-pc-windows-msvc]
# Increase default stack size to avoid running out of stack
# space in debug builds. The size matches Linux's default.
rustflags = ["-C", "link-arg=/STACK:8000000"]
toml

© 2026 SixtyFPS GmbH