Skip to content

Build command in 1.2.4 returns an error #204

@tjpnz

Description

@tjpnz

I created the hello_world project using the zig init command and then ran zig build-exe src/main.zig per section 1.2.4. It results in the following error:

% zig build-exe src/main.zig
src/main.zig:2:29: error: no module named 'hello_world' available within module 'main'
const hello_world = @import("hello_world");
                            ^~~~~~~~~~~~~
referenced by:
    main: src/main.zig:7:9
    callMain [inlined]: /opt/homebrew/Cellar/zig/0.15.2/lib/zig/std/start.zig:627:37
    callMainWithArgs [inlined]: /opt/homebrew/Cellar/zig/0.15.2/lib/zig/std/start.zig:587:20
    main: /opt/homebrew/Cellar/zig/0.15.2/lib/zig/std/start.zig:602:28
    1 reference(s) hidden; use '-freference-trace=5' to see all references

Furthermore, it looks like the files created using the init command are a bit different to those in the book. Output is different and the add function is declared using pub instead of export.

Is there a specific version of Zig I should have installed while working through the book?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions