Skip to content

Update for 0.15#6

Open
xaviershay wants to merge 3 commits intodundalek:masterfrom
xaviershay:master
Open

Update for 0.15#6
xaviershay wants to merge 3 commits intodundalek:masterfrom
xaviershay:master

Conversation

@xaviershay
Copy link

Attempting to address #5

Isn't linking ncurses properly yet :(

@xaviershay
Copy link
Author

Current states:

error: undefined symbol: egcpool_stash
    note: referenced by .zig-cache/o/3b73f5e436d25d087df4f3d61f4777b9/libnotcurses.a(.zig-cache/o/c5276b64a162aa49ab72f5e5ec8ca09b/blit.o/):.text
    note: referenced by .zig-cache/o/3b73f5e436d25d087df4f3d61f4777b9/libnotcurses.a(.zig-cache/o/31fd6a6015c69f1b684154d8bae5cb88/fill.o/):.text
    note: referenced by .zig-cache/o/3b73f5e436d25d087df4f3d61f4777b9/libnotcurses.a(.zig-cache/o/31fd6a6015c69f1b684154d8bae5cb88/fill.o/):.text
    note: referenced by .zig-cache/o/3b73f5e436d25d087df4f3d61f4777b9/libnotcurses.a(.zig-cache/o/95911d3853867f574fe8ab56fe85fef6/notcurses.o/):.text
    note: referenced 2 more times

@xaviershay xaviershay changed the title WIP: Start updating for 0.15 Update for 0.15 Sep 21, 2025
@xaviershay
Copy link
Author

egcpool_stash is provided by libnotcurses-core, which is no longer being built automatically. I added a make command to the README and uncommented the linking steps in build.zig.

This seems suboptimal, but it compiles and runs now!

});
pub usingnamespace c;

// Re-export the C symbols we need
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the re-export necessary now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have requisite experience or knowledge to answer this question

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently taking the baton here for making this work on 0.15 (and 0.16 to release soon).

This does not need to be re-exported. While usingnamespace was essentially removed entirely, we can just directly re-export via an alias:

pub const nc = @cImport({
    @cInclude("notcurses/notcurses.h");
});

Then using the lib is just a matter of:

const nc = @import("notcurses.zig").nc;

When 0.16 or 0.17 rolls around (depending on the issue status), @cImport will disappear in favour of direct declartion in the build script as a zig module instead (ziglang/zig#20630). So, that will essentially allow direct import like @import("notcurses") or something similar.

@dundalek
Copy link
Owner

I might not have time to test and merge this. I am a bit fatigued from Zig changes, my plan is to wait for 1.0.

We could perhaps add a link to your fork to the readme?

@xaviershay
Copy link
Author

xaviershay commented Sep 23, 2025

eh maybe just leave it. I literally just started hacking on something for a weekend project, I have no idea what I'm doing. Unlikely I'll be paying attention to this long term.

... my initial impression has too be leaning towards "wait for 1.0". Was pretty rough coming in and finding all libs broken (took me a bit to figure out that 0.15 only came out end of August, probably should have downgraded.)

"-std=gnu11",
"-D_GNU_SOURCE", // to make memory management work, see sys/mman.h
"-DUSE_MULTIMEDIA=none",
"-DUSE_QRCODEGEN=OFF",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to drop this define, since the C files make use of it with #ifdef without a value check.

.optimize = optimize,
});
exe_module.linkLibrary(notcurses);
exe_module.linkSystemLibrary("qrcodegen", .{});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this link as well if the previously mentioned define is removed

exe.addIncludePath(.{ .path = notcurses_source_path ++ "/include" });
exe.linkLibrary(notcurses);
exe.linkSystemLibrary("notcurses-core");
exe.addObjectFile(b.path(notcurses_source_path ++ "/build/libnotcurses-core.a"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither of seem to be needed as we are compiling the code into a Zig module, not building it externally into a static lib.

# In case of errors, try `git checkout v3.0.9` and re-run cmake as I tested it with this version.

# 0.15 UPDATE: The current build script requires make to built libncurses-core
make
Copy link

@EngineersBox EngineersBox Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't exactly true, if we're required to have an externally built static lib then sure, but since we are compiling the code into a zig module this is not necessary.

.optimize = optimize,
// notcurses has saome undefined benavior which makes the demo crash with
// illegal instruction, disabling UBSAN to make it work (-fno-sanitize-c)
.sanitize_c = std.zig.SanitizeC.off,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can add .link_libc = true, and remove the deprecated notcurses.linkLibC() usage below

exe_module.linkSystemLibrary("ncurses", .{});
exe_module.linkSystemLibrary("readline", .{});
exe_module.linkSystemLibrary("unistring", .{});
exe_module.linkSystemLibrary("z", .{});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be attached to the notcurses_module instead of exe_module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants