#is "zig build-exe src/main.zig" supposed to succeed after running "zig init"?

1 messages · Page 1 of 1 (latest)

limber void
#

Hello!

I'm running "zig build-exe src/main.zig" after running all steps up to here: https://pedropark99.github.io/zig-book/Chapters/01-zig-weird.html#sec-compile-code

Is this resource (which I got from the top of the online learning resources on the zig website) incorrect / out of date or does this mean
that my zig installation is incorrect?

zig version
0.15.2
mkdir hw
cd hw
zig init
info: created build.zig
info: created build.zig.zon
info: created src/main.zig
info: created src/root.zig
info: see `zig build --help` for a menu of options
# zig build works
zig build
 ./zig-out/bin/hw
All your codebase are belong to us.
Run `zig build test` to run the tests.
# zig build-exe does not
zig build-exe src/main.zig
src/main.zig:2:20: error: no module named 'hw' available within module 'main'
const hw = @import("hw");
                   ^~~~
referenced by:
    main: src/main.zig:7:9
    callMain [inlined]: /home/user/.local/bin/lib/std/start.zig:627:37
    callMainWithArgs [inlined]: /home/user/.local/bin/lib/std/start.zig:587:20
    posixCallMainAndExit: /home/user/.local/bin/lib/std/start.zig:542:36
    2 reference(s) hidden; use '-freference-trace=6' to see all references

 ./main
zsh: exec format error: ./main

native thorn
#

if ur using build.zig, u should use zig build instead of zig build-exe

limber void
#

ok, is the zig-book above still a resource you would recommend to someone trying to learn zig?

#

also ty very much for your quick response!!!

native thorn
limber void
#

ok, ty very much! I really appriciate the help