Get include path for zig.h

I’m using Zig 0.11.0 and in a build.zig I’m trying to pass the path of the directory containing the zig.h shipped with Zig as include directory to an external tool, i.e. what zig env returns as "lib_dir".

I looked into the source code of the zig env command and found that it uses introspect.zig which does not seem to be part of the standard library.

I found Getting the zig compiler path in build.zig. Do I have to manipulate the path to the Zig executable returned by b.zig_exe or is there a better way?

You can get the zig.exe path using std.fs.selfExeDirPath
Then call std.fs.path.dirname to remove the bin part.
Finally call std.fs.path.join to add lib.

do you mean getSelfExePath? (that’s where your link goes)
and the docs give this advice.

 If you only need the directory, use selfExeDirPath

Thank you. I meant selfExeDirPath.

The std.fs.selfExe[…] family of functions is not what I need here, they refer to the executable that is executing the build (the result of compiling build.zig), somewhere in zig-cache/o/…, not the zig executable itself.

It seems b.zig_exe and then replacing the trailing /zig with /lib is indeed the way to go.