#Compiler does not see the dependency

1 messages · Page 1 of 1 (latest)

potent spire
#

I was gonna make a simple OpenGL project using zgl and zglfw. zgl linked correctly, and it works. However, when trying to import zglfw, the compiler throws out an error.

root.zig, build.zig, main.zig and the error message are included as files (discord won't let me paste them here, sorry).

#

if there's a need i could paste my build.zig.zon

#

The most important parts or build.zig are:

    const zgl = b.dependency("zgl", .{
        .target = target,
        .optimize = optimize,
    });
    exe.root_module.addImport("zgl", zgl.module("zgl"));

    const zglfw = b.dependency("zglfw", .{});
    exe.root_module.addImport("zglfw", zglfw.module("root"));

    if (target.result.os.tag != .emscripten) {
        exe.linkLibrary(zglfw.artifact("glfw"));
    }

    exe.linkSystemLibrary("glfw");
    exe.linkSystemLibrary("GL");
    exe.linkSystemLibrary("X11");
    exe.linkSystemLibrary("Xrandr");
    exe.linkSystemLibrary("Xi");
    exe.linkSystemLibrary("dl");
    exe.linkSystemLibrary("m");
#

and linking in src/root.zig is done with:

const glfw = @import("zglfw");
#

i fetched all the dependencies with zig fetch --save <url>

pliant nymph
#

are you trying to import zglfw in the Ray_marching_OpenGL src/root.zig module?

pliant nymph
#

your calling addImport on the exes root module but not on the mod created on line 31, so you would be able to access the import in main.zig but not in root.zig

#

this is why i dont like the main.zig/root.zig split

#

i would delete mod line 31 to 42 and just merge main.zig and root.zig

potent spire
#

Thanks!

#

I'll fix all the error and tell you if it worked

#

I've fixed the all the errors that i had, and now it works perfectly

#

also zgl has a really nice error system compared to C/C++ OpenGL

#

i really enjoy zig :)