Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions doc/langref.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -10901,9 +10901,15 @@ export fn add(a: i32, b: i32) i32 {
}
{#code_end#}
<p>To make a static library:</p>
{#shell_samp#}$ zig build-lib mathtest.zig{#end_shell_samp#}
{#shell_samp#}$ zig build-lib -femit-h mathtest.zig{#end_shell_samp#}
<p>To make a shared library:</p>
{#shell_samp#}$ zig build-lib mathtest.zig -dynamic{#end_shell_samp#}
{#shell_samp#}$ zig build-lib -femit-h mathtest.zig -dynamic{#end_shell_samp#}
<p>
The <kbd>-femit-h</kbd> flag is necessary in order to generate the mathtest.h file.
The generated C header file includes the zig.h file that must be copied
to the project directory, as an example using <a href="https://stedolan.github.io/jq/">jq</a>:
</p>
{#shell_samp#}cp $(zig env | jq -r .lib_dir)/zig.h .{#end_shell_samp#}
Copy link
Member

Choose a reason for hiding this comment

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

A command like this shouldn't be needed to use -femit-h and should be fixed before documenting -femit-h.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The command is not needed to use -femit-h, but to copy the zig.h file to the current directory. Without the zig.h file zig build fails on my system.

Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

I know and it shouldn't be needed for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you set the CPATH environment variable manually?

I also tried with the new official zig 0.10.0 package from Archlinux, but zig.h is not found (it is installed in /usr/lib/zig/include/zig.h.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't set anything, I get all the same errors as you do. What I meant is that you shouldn't need to copy anything or set some environment variable, zig.h should either not be referenced by the emitted header or it should be installed alongside it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I misunderstood what you wrote. Thanks.
I will open an issue.

<p>Here is an example with the {#link|Zig Build System#}:</p>
{#syntax_block|c|test.c#}// This header is generated by zig from mathtest.zig
#include "mathtest.h"
Expand Down