Segmentation Fault (Core Dumped) When Using zig build-lib -femit-h on mathtest.zig with Zsh

I am currently trying around with C-Interop and trying to generate C-Header files.
I found a Stackoverflow. I still can’t figure out how to do that.
When using zig build-lib -femit-h mathtest.zig i get a segmentation fault (core dumped) error. Any advice?

Can you post the contents of mathtest.zig so we can examine it?

Of course:

export fn add(a: i32, b: i32) i32 {
    return a + b;
}

It requires linking with libc.
zig build-lib -lc -femit-h mathtest.zig

Thanks that worked. It is now searching for an zig.h file. Where is this file located?

It is located in the lib directory of the zig installation.

1 Like