I’m stuck on Stage #QP2 using zig.
I have used the dynamic readline library for the autocomplete part and the project builds upon zig build and properly runs on my machine, but for some reason codecrafters test fails and tells me unable to find dynamic library readline.
I have checked and a libreadline.so file is present in the /usr/lib/x86_64-linux-gnu/
Here are the error logs codecrafters test generates
`
[build] > install
[build] > +- install main
[build] > +- compile exe main Debug native failure
[build] > error: error: unable to find dynamic system library 'readline' using strategy 'paths_first'. searched paths:
[build] > /usr/local/lib/libreadline.so
[build] > /usr/local/lib/libreadline.a
[build] > /usr/lib/x86_64-linux-gnu/libreadline.so
[build] > /usr/lib/x86_64-linux-gnu/libreadline.a
[build] > /lib64/libreadline.so
[build] > /lib64/libreadline.a
[build] > /lib/libreadline.so
[build] > /lib/libreadline.a
[build] > /usr/lib64/libreadline.so
[build] > /usr/lib64/libreadline.a
[build] > /usr/lib/libreadline.so
[build] > /usr/lib/libreadline.a
[build] > /lib/x86_64-linux-gnu/libreadline.so
[build] > /lib/x86_64-linux-gnu/libreadline.a
[build] >
[build] > error: the following command exited with error code 1:
[build] > /usr/local/zig/zig build-exe -lreadline -Mroot=/app/src/main.zig -lc --cache-dir .zig-cache --global-cache-dir /root/.cache/zig --name main --zig-lib-dir /usr/local/zig/lib/ --listen=-
[build] >
[build] > Build Summary: 0/3 steps succeeded; 1 failed
[build] > install transitive failure
[build] > +- install main transitive failure
[build] > +- compile exe main Debug native failure
[build] >
[build] > error: the following build command failed with exit code 1:
[build] > .zig-cache/o/dcc5588e474b7e2fa4a8ea980e83ec1c/build /usr/local/zig/zig /usr/local/zig/lib /app .zig-cache /root/.cache/zig --seed 0xd82a498f -Z0db0325470f2bad4
[build] Error: process "/bin/sh -c .codecrafters/compile.sh" did not complete successfully: exit code: 1.
[build] > error: the following command exited with error code 1:
[build] > /usr/local/zig/zig build-exe -lreadline -Mroot=/app/src/main.zig -lc --cache-dir .zig-cache --global-cache-dir /root/.cache/zig --name main --zig-lib-dir /usr/local/zig/lib/ --listen=-
[build] >
[build] > Build Summary: 0/3 steps succeeded; 1 failed
[build] > install transitive failure
[build] > +- install main transitive failure
[build] > +- compile exe main Debug native failure
[build] >
[build] > error: the following build command failed with exit code 1:
[build] > .zig-cache/o/dcc5588e474b7e2fa4a8ea980e83ec1c/build /usr/local/zig/zig /usr/local/zig/lib /app .zig-cache /root/.cache/zig --seed 0xd82a498f -Z0db0325470f2bad4
`
const std = @import(“std”);
// Learn more about this file here: https://ziglang.org/learn/build-system
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = “main”,
.root_module = b.createModule(.{
.root_source_file = b.path(“src/main.zig”),
.target = b.graph.host,
}),
});
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
// step when running `zig build`).
exe.root_module.link_libc = true;
exe.root_module.linkSystemLibrary("readline", .{});
b.installArtifact(exe);
// This *creates* a Run step in the build graph, to be executed when another
// step is evaluated that depends on it. The next line below will establish
// such a dependency.
const run_cmd = b.addRunArtifact(exe);
// This creates a build step. It will be visible in the `zig build --help` menu,
// and can be selected like this: `zig build run`
// This will evaluate the `run` step rather than the default, which is "install".
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// This allows the user to pass arguments to the application in the build
// command itself, like this: `zig build run -- arg1 arg2 etc`
if (b.args) |args| {
run_cmd.addArgs(args);
}
}