8000 Fails to compile on zig 0.14 / MacOS · Issue #243 · zigimg/zigimg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fails to compile on zig 0.14 / MacOS #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By 8000 clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
loftafi opened this issue Mar 17, 2025 · 6 comments
Open

Fails to compile on zig 0.14 / MacOS #243

loftafi opened this issue Mar 17, 2025 · 6 comments

Comments

@loftafi
Copy link
loftafi commented Mar 17, 2025

I could be doing something wrong, but as far as I can tell, this library doesn't work on zig 0.14 using the most recent version.

const zigimg = @import("zigimg");

pub fn main() !void {
    var file = try std.fs.cwd().openFile("test.png", .{});
    var img = try zigimg.Image.fromFile(std.heap.smp_allocator, &file);
    defer img.deinit();
}

const std = @import("std");

Here is the error:

% zig build
install
└─ install zigimg_test
   └─ zig build-exe zigimg_test Debug native 1 errors
/Users/user/.cache/zig/p/zigimg-0.1.0-AAAAAABoEABi8SAnVIitstXxPM3Szg3PHDsOtcnhKm6s/src/formats/png/reader.zig:981:43: error: missing struct field: remap
pub const NoopAllocator = Allocator.VTable{ .alloc = undefined, .free = undefined, .resize = undefined };
                          ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/user/zig/zig-macos-aarch64-0.14.0/lib/std/mem/Allocator.zig:22:20: note: struct declared here
pub const VTable = struct {
                   ^~~~~~

Here is a minimal example project:

https://github.com/loftafi/zigimg_test

@mlarouche
Copy link
Collaborator

We only support mach nominated versions, see the README: https://github.com/zigimg/zigimg?tab=readme-ov-file#install--build

@mlarouche
Copy link
Collaborator

That compile error will be fixed once a new mach nominated Zig version is out with these changes

@Khitiara
Copy link
Khitiara commented May 3, 2025

I thought mach nominated builds were meant to include zig stable? with the mach builds filling in the gaps between stable

@loftafi
Copy link
Author
loftafi commented May 6, 2025

All the other libraries I use have bug fixes only applied to a zig 0.14 compatible branch. So I was forced into upgrading zig 0.14. So I was forced out of using zigimg.

For people forced by other projects to track, stable, I found something called stb which can reimported as a c header, and it works great. (Well at least it works great with zig 0.14) Although it would be better if we had a native zig solution that did support zig stable.

@zaddok
Copy link
zaddok commented May 20, 2025

Is there a branch of this library that resolves the build issue? It looks like something to do with the changes to the memory allocator. Is there a "ready to go" branch for using this with the latest stable zig?

Is it true that it's only a few lines of code to get it working on zig 0.14? Perhaps the Noop allocator can be changed so that it is compatible with both 0.13 and 0.14? See this patch:

master...AdamBrutsaert:zigimg:master

@loftafi
Copy link
Author
loftafi commented May 20, 2025

I have created an updated fork using the latest zigimg, and applying the patches from the above slightly older fork.

https://github.com/loftafi/zigimg/tree/master

This solves it for me temporarily. I am not sure if I should close this ticket. I guess I should leave it open because other people are still going to stumble across the same problem.

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

No branches or pull requests

4 participants
0