-
|
os: NixOS 25.11 I'm using the qtbase package from nixpkgs, and this custom build script, instead of the one from examples const std = @import("std");
const base_libs = [_][]const u8{
"Qt6Core",
"Qt6Gui",
"Qt6Widgets",
};
const static_libs = [_][]const u8{
"qapplication",
"qwidget",
"qlayout",
"qboxlayout",
"qstackedwidget",
"qlabel",
"qlineedit",
"qabstractbutton",
"qpushbutton",
};
pub fn build(b: *std.Build) void {
const allocator = b.allocator;
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const extra_paths: []const []const u8 = &.{ std.process.getEnvVarOwned(allocator, "QT6_PATH") catch "" };
// Modules
const qt6zig = b.dependency("libqt6zig", .{
.target = target,
.optimize = optimize,
.@"extra-paths" = extra_paths,
});
const ui_module = b.addModule("ui", .{
.root_source_file = b.path("src/ui/root.zig"),
});
const exe = b.addExecutable(.{
.name = "navigator",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
// Imports
ui_module.addImport("libqt6zig", qt6zig.module("libqt6zig"));
exe.root_module.addImport("libqt6zig", qt6zig.module("libqt6zig"));
exe.root_module.addImport("ui", ui_module);
// Linking
const sub_paths = [_][]const u8{ "/bin", "/lib", "" };
for (extra_paths) |path| {
for (sub_paths) |sub_path| {
const extra_path = b.fmt("{s}{s}", .{ path, sub_path });
std.fs.cwd().access(extra_path, .{}) catch {
continue;
};
exe.root_module.addLibraryPath(std.Build.LazyPath{ .cwd_relative = extra_path });
}
}
for (base_libs) |lib| {
exe.root_module.linkSystemLibrary(lib, .{});
}
for (static_libs) |lib| {
exe.root_module.linkLibrary(qt6zig.artifact(lib));
}
// Install
b.installArtifact(exe);
// Run step
const run_step = b.step("run", "Run the app");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
}The application compiles fine, links fine (I checked with ldd to see if the correct libs where linked, and they were), but when I run the program, it segfaults every time on qwidget.Show(). This is the error: The following is the snippet of code involved: const argc = std.os.argv.len;
const argv = std.os.argv.ptr;
const app = qapplication.New(argc, argv);
defer qapplication.QDelete(app);
const window = try ui.Window.New(allocator);
defer qwidget.QDelete(window.widget);
qwidget.Show(window.widget);
_ = qapplication.Exec();I thought the problem was with my nixos developer shell, but I tried downloading the libqt6zig-examples repo, opened my shell from and it compiled and ran without problems. The problem is probably within the build script, as I cut down everything I thought was unnecessary from the libqt6zig-examples one, but I cant find what's (probably) missing. The full repo of the project, is here |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hi! Thanks for the interest!
Take a look at the demo for a simpler build system. It was designed for this purpose.
The issue is that the Debug build mode is currently not supported. Any of the release options work. Beautiful app so far!
The Debug build mode did work on Zig 0.13 but has regressed since Zig 0.14. I hope to be able to restore it at some point because it was such a great development and debugging experience that I want others to experience too. |
Beta Was this translation helpful? Give feedback.

Hi! Thanks for the interest!
Take a look at the demo for a simpler build system. It was designed for this purpose.
The issue is that the Debug build mode is currently not supported. Any of the release options work. Beautiful app so far!
The Debug build mode did work on Zig 0.13 but has regressed since Zig …