Build system: create_module recent changes

Hi.
I recently updated to the latest build of the compiler and now my build.zig no longer works. I have created a module with create_module. I used to add it to the exe with exe.add_module(). This no longer works and I can’t figure out how to connect my module to the executable.
Appreciate any help!

To create a private module to use withing your project:

    const mod = b.createModule(.{
        .root_source_file = .{ .path = "src/mod.zig" },
        .target = target,
        .optimize = optimize,
    });

and then you add it to your exe:

exe.root_module.addImport("mod", mod);

If you want to provide the module for users to use in their projects, use addModule instead:

    const mod = b.addModule("mod", .{
        .root_source_file = .{ .path = "src/mod.zig" },
        .target = target,
        .optimize = optimize,
    });

@dude_the_builder Ahh. .root_module… almost as if they were hiding it :wink:
Thank you!!

1 Like