Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

perillo
Copy link
Contributor

@perillo perillo commented Jan 19, 2023

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 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#}
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.

@perillo
Copy link
Contributor Author

perillo commented Jan 19, 2023

I found an open issue for the same problem of mathtest.h not being generated: #6753.

@perillo
Copy link
Contributor Author

perillo commented Jan 22, 2023

FYI: In addition to the the "Exporting a C Library" example, there is another not working example in the "Mixing Object Files" example.

@andrewrk andrewrk closed this Jan 23, 2023
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

Successfully merging this pull request may close these issues.

3 participants