0

I was doing work for a project for a http server in Zig. I wanted to use sqlite3 as my database. I then looked sqlite client for Zig and found the github repo karlseguin/zqlite.zig and decided to use it. No matter what way I try it does not work. Every time I run or build my project all I get is a :

zig build-exe freight Debug native: error: the following command fail
ed with 2 compilation errors:
/snap/zig/8046/zig build-exe /home/hp/.github/freight/src/main.zig -l
c++ -lc --cache-dir /home/hp/.github/freight/zig-cache --global-cache
-dir /home/hp/.cache/zig --name freight --mod zqlite::/home/hp/.cache
/zig/p/1220674f94780f2d25be8d54a5b1aa7e1db3d1eac4f0a164e3ec9fd0362238
04462f/zqlite.zig --deps zqlite --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary 
none)
install transitive failure
└─ install freight transitive failure
   └─ zig build-exe freight Debug native 2 errors
/home/hp/.cache/zig/p/1220674f94780f2d25be8d54a5b1aa7e1db3d1eac4f0a16
4e3ec9fd036223804462f/zqlite.zig:3:11: error: C import failed
const c = @cImport(@cInclude("sqlite3.h"));
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    Create: /home/hp/.cache/zig/p/1220674f94780f2d25be8d54a5b1aa7e1db
3d1eac4f0a164e3ec9fd036223804462f/zqlite.zig:6:21
    main: src/main.zig:5:35
    remaining reference traces hidden; use '-freference-trace' to see
 all reference traces

/home/hp/.github/freight/zig-cache/o/faabcee71bc25c1918d07dfbcccb8c6c
/cimport.h:1:10: error: 'sqlite3.h' file not found
#include <sqlite3.h>
         ^

Error.

I imported the module through build.zig.zon file. The build.zig.zon file:

.{
  .name = "freight",
  .version = "0.0.1",
  .dependencies = .{
    .zqlite = .{ 
      .url = "https://github.com/karlseguin/zqlite.zig/archive/347a7abd948649a164538963696fedf31297b707.tar.gz",
      .hash = "1220674f94780f2d25be8d54a5b1aa7e1db3d1eac4f0a164e3ec9fd036223804462f",
    }
  }
}

The build.zig file:

const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const exe = b.addExecutable(.{
        .name = "freight",
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    });

    const zqlite = b.dependency("zqlite", .{
        .target = target,
        .optimize = optimize
    });

    exe.addModule("zqlite", zqlite.module("zqlite"));
    exe.linkLibC();

    b.installArtifact(exe);

    const run_cmd = b.addRunArtifact(exe);

    run_cmd.step.dependOn(b.getInstallStep());

    if (b.args) |args| {
        run_cmd.addArgs(args);
    }

    const run_step = b.step("run", "Run the app");
    run_step.dependOn(&run_cmd.step);

    const unit_tests = b.addTest(.{
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    });

    const run_unit_tests = b.addRunArtifact(unit_tests);

    const test_step = b.step("test", "Run unit tests");
    test_step.dependOn(&run_unit_tests.step);
}

Is there a solution for this problem?

  • You should report this as a bug to the [zqlite.zig](https://github.com/karlseguin/zqlite.zig) developers. – sigod Aug 12 '23 at 14:48

0 Answers0