#Error: file exists in modules ...

1 messages · Page 1 of 1 (latest)

rocky blade
#

This is my error code:

src\main.zig:1:1: note: files must belong to only one module
src\main.zig:1:1: note: file is the root of module 'root'
src\main.zig:1:1: note: file is the root of module 'ray_directory'```

What is confusing me is that my build-script is virtually identical to another similar script that *is* working. I can hash out that it is something with the modules importing the same thing, however I can't explain why that would be a problem.

Could someone explain what is going on?

I will post my build script, in a moment
#

My Build Script:

const std = @import("std");
const Import = std.Build.Module.Import;

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

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

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


    const common_imports = [_] Import { 
        .{.name = "raylib", .module = raylib_dep.module("raylib")},
        .{.name = "network", .module = network_dep.module("network")},
    };

    const DirectorySearch = b.createModule(.{
        .target = target,
        .optimize = optimize,
        .root_source_file = b.path("src/main.zig"),
        .imports = & [1] Import {
            //.{.name = "raylib", .module = raylib_dep.module("raylib")}
            common_imports[0], // neither this nor the above works
        },
    });


    const exe = b.addExecutable(.{
        .name = "file_share",
        .root_module = b.createModule(.{
            .target = target,
            .optimize = optimize,
            .root_source_file = b.path("src/main.zig"),
            .imports = &common_imports,
        }),
    });

    exe.root_module.addImport("ray_directory", DirectorySearch);
    exe.linkLibrary(raylib_dep.artifact("raylib"));
    b.installArtifact(exe);

    const run_step = b.step("run", "run the program");
    const run_cmd = b.addRunArtifact(exe);
    run_step.dependOn(&run_cmd.step);
    run_cmd.step.dependOn(b.getInstallStep());
}```
thorny silo
#

well youre using main.zig for DirectorySearch and exe

rocky blade
#

I thought my build scripts look similar