-
Notifications
You must be signed in to change notification settings - Fork 47
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
How to install liblua.a
?
#18
Comments
Hi @atweiden! This is a known issue (see #13). The package manager that will be part of the 0.11.0 release has some of the pieces required for this to work, but we are still waiting on a PR to be merged. Once the package manager can handle exposing data other than Zig modules, this will become easy. The code would look something like this in a const ziglua = b.dependency("ziglua", .{
.target = target,
.optimize = optimize,
});
// here is the library "liblua.a" and can be linked against anything you need, or written to a file
ziglua.artifact("lua"); There may be a way to get this fixed sooner, but I am inclined to wait until the package manager properly supports this use case. Let me know if I misunderstood anything! |
Hi @atweiden, sorry for the long wait on this. This is now fixed and I tested to verify this works. The readme has been updated with build instructions that use the new package manager. Here is an example that shows how to link the artifact with your project, and how to write the lua library artifact to the output folder. // build.zig.zon
.{
.name = "array",
.version = "0.0.1",
.dependencies = .{
.ziglua = .{
.url = "https://github.com/natecraddock/ziglua/archive/ab111adb06d2d4dc187ee9e1e352617ca8659155.tar.gz",
.hash = "12206cf9e90462ee6e14f593ea6e0802b9fe434429ba10992a1451e32900f741005c",
},
}
}
// build.zig
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const ziglua = b.dependency("ziglua", .{
.target = target,
.optimize = optimize,
});
const lib = b.addSharedLibrary(.{
.name = "array",
.root_source_file = .{ .path = "src/array.zig" },
.target = target,
.optimize = optimize,
});
// These lines link lua to the output library
lib.addModule("ziglua", ziglua.module("ziglua"));
lib.linkLibrary(ziglua.artifact("lua"));
// This line installs liblua to the zig-out/lib/ directory
b.installArtifact(ziglua.artifact("lua"));
b.installArtifact(lib);
} Let me know if you need anything else! |
liblua.a
is available in thezig-cache/
directory after runningziglua.compileAndCreateModule
in my project’sbuild.zig
. Can ziglua possibly installliblua.a
intozig-out/
? This would help in doing Zig-Go interop — I’d like Go to link against thisliblua.a
. Perhaps there’s a way of doing this from my project’sbuild.zig
The text was updated successfully, but these errors were encountered: