#Errors in output when adding simple test-dependency into my project with `zon`.

1 messages · Page 1 of 1 (latest)

lucid socket
#

I've created simple zig module to connect it into my another project with test purposies:
https://github.com/Xenely14/zig-fiblib

After running zig build its compiles successfully and output of my program is correct, but i yet getting error in output like that:

GitHub

Contribute to Xenely14/zig-fiblib development by creating an account on GitHub.

#

Here is how looks like my build.zig:

const std = @import("std");

pub fn build(b: *std.Build) !void {
    var target = b.standardTargetOptions(.{});
    target.cpu_arch = .x86_64;
    target.os_tag = .windows;
    target.abi = .msvc;

    var optimize = b.standardOptimizeOption(.{});
    optimize = .ReleaseSmall;

    // dependencies
    const fiblib = b.dependency("fiblib", .{
        .target = target,
        .optimize = optimize,
    });

    // exe
    var exe = b.addExecutable(.{
        .name = "main",
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("fiblib", fiblib.module("fiblib"));
    b.installArtifact(exe);
}

build.zig.zon:

.{
    .name = "my-project",
    .version = "0.0.0",

    .dependencies = .{
        .fiblib = .{
            .url = "https://github.com/Xenely14/zig-fiblib/archive/9ce476da94289b76f418208ed9f6ac65d8f93b0c.tar.gz",
            .hash = "122041d86adb3e46b6ac93066e36640b370a87bd2ff213e44346e766fd805dd31a9a",
        },
    },

    .paths = .{""},
}

And src/main.zig:

const std = @import("std");
const fiblib = @import("fiblib");

pub fn main() !void {
    var fibonacci_value = fiblib.fibonacci(usize, 10);
    std.debug.print("Value is -> {d}\n", .{fibonacci_value});
}

#

What's wrong here? And how can i fix that?

quick osprey
#

zig-fiblib doesnt declare any target or optimize options but youre trying to pass them

#

just remove the

.target = target,
.optimize = optimize,
lucid socket
quick osprey
#

theres no point for those options in your case since they wouldnt be used anywhere in the library

lucid socket
#

I'm just trying to figure out how this works, it's would be nice to know how to do that to use it in another real projects

lucid socket
quick osprey
#

well you said you wanted to know how to do it for other projects :p
in this case the options arent used and wont do anything since its a pure zig project

#

if the dependency did something like building a library thats when you would add those options but that isnt the case here

lucid socket