# What happened to addModule?

**URL:** <https://ziggit.dev/t/what-happened-to-addmodule/2908>\
**Category:** Help\
**Tags:** build-system\
**Created:** [January 18, 2024, 6:18pm UTC](https://ziggit.dev/t/what-happened-to-addmodule/2908 "2024-01-18T18:18:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chung-leong](https://ziggit.dev/user_avatar/ziggit.dev/chung-leong/32/999_2.png) [@chung-leong](https://ziggit.dev/u/chung-leong)\
**Post date:** [January 18, 2024, 6:18pm UTC](https://ziggit.dev/t/what-happened-to-addmodule/2908/1 "2024-01-18T18:18:21Z")

</div>

Up til now I’ve been working only in Zig 0.11. Today I decided to install master (using zvm) so that I can get a sense of what changes the upcoming release of Zig will entail. Immediately I hit the following error:

```zig
/tmp/e1bde732f5b919a56f97e346aa6d5683/linux/x64/build.zig:15:8: error: no field or member function named 'addModule' in 'Build.Step.Compile'

```

A scan of the documentation didn’t readily reveal what the replacement function is. I’m sure one of you must know what the new way of doing thing is. Here’s the build file:

```zig
const std = @import("std");
const cfg = @import("./build-cfg.zig");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{
        .default_target = cfg.target,
    });
    const optimize = b.standardOptimizeOption(.{});
    const lib = b.addSharedLibrary(.{
        .name = cfg.package_name,
        .root_source_file = .{ .path = cfg.stub_path },
        .target = target,
        .optimize = optimize,
    });
    lib.addModule("exporter", b.createModule(.{
        .source_file = .{ .path = cfg.exporter_path },
    }));
    lib.addModule("package", b.createModule(.{
        .source_file = .{ .path = cfg.package_path },
    }));
    if (cfg.use_libc) {
        lib.linkLibC();
    }
    if (cfg.target.cpu_arch == .wasm32) {
        lib.use_lld = false;
        lib.rdynamic = true;
    }
    b.installArtifact(lib);
}

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![tensorush](https://ziggit.dev/letter_avatar_proxy/v4/letter/t/6a8cbe/32.png) [@tensorush](https://ziggit.dev/u/tensorush)\
**Post date:** [January 18, 2024, 6:25pm UTC](https://ziggit.dev/t/what-happened-to-addmodule/2908/2 "2024-01-18T18:25:23Z")

</div>

Yeah, so the new way is kinda ugly, you need to substitute `.addModule` with `root_module.addImport`. I’m sure it’ll change several more times as the team iterates on the package manager.

---

<div class="post-metadata">

**Author:** ![chung-leong](https://ziggit.dev/user_avatar/ziggit.dev/chung-leong/32/999_2.png) [@chung-leong](https://ziggit.dev/u/chung-leong)\
**Post date:** [January 18, 2024, 6:48pm UTC](https://ziggit.dev/t/what-happened-to-addmodule/2908/3 "2024-01-18T18:48:15Z")

</div>

> [@tensorush](#):
>
> addImport

Thanks a lot for the pointer! So the build file ended up looking like this:

```zig
const std = @import("std");
const cfg = @import("./build-cfg.zig");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{
        .default_target = cfg.target,
    });
    const optimize = b.standardOptimizeOption(.{});
    const lib = b.addSharedLibrary(.{
        .name = cfg.package_name,
        .root_source_file = .{ .path = cfg.stub_path },
        .target = target,
        .optimize = optimize,
    });
    lib.root_module.addImport("exporter", b.createModule(.{
        .root_source_file = .{ .path = cfg.exporter_path },
    }));
    lib.root_module.addImport("package", b.createModule(.{
        .root_source_file = .{ .path = cfg.package_path },
    }));
    if (cfg.use_libc) {
        lib.linkLibC();
    }
    if (cfg.target.cpu_arch == .wasm32) {
        lib.use_lld = false;
        lib.rdynamic = true;
    }
    b.installArtifact(lib);
}

```

The only incompatibility I’m seeing so far is `std.builtin.Endian.Little` being all lowercase now.
