Skip to content

Proper way to reuse c headers from the exposed lua library #78

@bfredl

Description

@bfredl

In addition to using the @import("ziglua") module from zig code, I need to compile additional C extensions which depend on the headers for the correct lua version as exposed by ziglua.

After some trial and error I found this to work:

    my_module.addImport("ziglua", ziglua.module("ziglua"));
    // addImport already links by itself. but we need headers as well..
    my_module.linkLibrary(ziglua.artifact("lua"));

This feels a bit hacky as it relies on the artifact name "lua" which might be seen as internal to ziglua (not part of the exported module), and also, as addImport by itself is enough to add the .o files for the lua library, linkLibrary would add the same objects a second time?
This should "safely" be handled gracefully by most linkers, but it would be best to avoid this if possible.

Any thoughts about what the proper way would be?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions