我正在尝试将 X11 与 Zig 一起使用。以https://rosettacode.org/wiki/Window_creation/X11#Xlib中的代码为例,我想出了这个最小的例子:
const c = @cImport({
@cInclude("X11/Xlib.h");
});
pub fn main() void {
var maybe_display : ?*c.Display = c.XOpenDisplay(@as(?*u8, null));
}
使用最新版本的 Zig (0.6.0) 编译:
zig build-exe -lX11 main.zig
在执行时,我收到以下错误:
Segmentation fault at address 0x0
attempt to unwrap error: InvalidExe
Panicked during a panic. Aborting.
fish: './main' terminated by signal SIGABRT (Abort)