Windows
我们在以下 Windows 版本和架构上测试 Slint:
| 操作系统 | 架构 |
|---|---|
| Windows 10 | x86-64 |
| Windows 11 | x86-64, aarch64 |
处理控制台窗口
Section titled “处理控制台窗口”运行应用程序时,默认会显示一个控制台窗口。
要禁用控制台,请将 WINDOWS 指定为子系统。
从命令行运行应用程序时,如果子系统设置为 WINDOWS,它将不再输出 stdout。如果你需要 stdout,可以考虑使用 FreeConsole()。
更多细节请参见 #3235。
将以下代码添加到包含 fn main() 的 .rs 文件顶部:
#![windows_subsystem = "windows"]rust
如果你想在 debug 模式下保留控制台输出:
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]rust
通过在你的可执行目标上设置 WIN32_EXECUTABLE 目标属性来选择 WINDOWS 子系统:
add_executable(my_program ...)set_property(TARGET my_program APPEND PROPERTY WIN32_EXECUTABLE TRUE)cmake
将 Python 脚本的扩展名从 .py 改为 .pyw。这样与 Python 文件关联的默认
Python 解释器就会在没有控制台窗口的情况下启动。或者,使用 pythonw.exe 而不是
python.exe 来启动你的 Python 脚本。
Rust:栈溢出
Section titled “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