-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 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
doctest: make the "Exporting a C Library" example work #14378
Conversation
The mathtest example of exporting a library with the C ABI it not working, since the mathtest.h file is not generated. Update the shell sample, adding the -femit-h flag to the zig build-lib command. Show an example of how to copy the zig.h file to the project directory, using zig env and jq. I'm not sure if there is a better/official method.
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#} |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I found an open issue for the same problem of |
FYI: In addition to the the "Exporting a C Library" example, there is another not working example in the "Mixing Object Files" example. |
The mathtest example of exporting a library with the C ABI it not working, since the mathtest.h file is not generated.
Update the shell sample, adding the -femit-h flag to the zig build-lib command.
Show an example of how to copy the zig.h file to the project directory, using zig env and jq. I'm not sure if there is a better/official method.