Error: no field named 'source_file' in struct 'Build.Module.CreateOptions'

I tried to build this Karl Seguin’s example with 0.12 and got an error:

learning-zig-rus/src/examples/ex-ch09-08$ /opt/zig-0.12/zig build
learning-zig-rus/src/examples/ex-ch09-08/build.zig:9:10: error: no field named 'source_file' in struct 'Build.Module.CreateOptions'
        .source_file = .{ .path = "calc/calc.zig" },
         ^~~~~~~~~~~
/opt/zig-0.12/lib/std/Build/Module.zig:139:27: note: struct declared here
pub const CreateOptions = struct {
                          ^~~~~~
referenced by:
    runBuild__anon_8991: /opt/zig-0.12/lib/std/Build.zig:2080:37
    main: /opt/zig-0.12/lib/compiler/build_runner.zig:300:29
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

How to fix this?

The field name changed to root_source_file.

thanks, worked.

then I am getting

learning-zig-rus/src/examples/ex-ch09-08$ /opt/zig-0.12/zig build
/home/zed/2-coding/zig-lang/learning-zig-rus/src/examples/ex-ch09-08/build.zig:19:8: error: no field or member function named 'addModule' in 'Build.Step.Compile'
    exe.addModule("calc", calc_module);
    ~~~^~~~~~~~~~
/opt/zig-0.12/lib/std/Build/Step/Compile.zig:1:1: note: struct declared here
const builtin = @import("builtin");
^~~~~
referenced by:
    runBuild__anon_8991: /opt/zig-0.12/lib/std/Build.zig:2080:37
    main: /opt/zig-0.12/lib/compiler/build_runner.zig:300:29
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

and that changed to exe.root_module.addImport. Ah, the joy of living on the bleeding edge. :joy_cat:

3 Likes

will try later

thanks once again, now it’ working.

1 Like