jedisct1 / dsvpn

A Dead Simple VPN.
MIT License
5.17k stars 395 forks source link

zig build gives error #97

Closed pepa65 closed 1 year ago

pepa65 commented 1 year ago

zig build:

/data/git/dsvpn/build.zig:7:20: error: member function expected 1 argument(s), found 2
    const dsvpn = b.addExecutable("dsvpn", null);
                  ~^~~~~~~~~~~~~~
/opt/zig/lib/std/Build.zig:489:5: note: function declared here
pub fn addExecutable(b: *Build, options: ExecutableOptions) *Step.Compile {
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    runBuild__anon_7136: /opt/zig/lib/std/Build.zig:1639:37
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

zig version: 0.11.0

jedisct1 commented 1 year ago

Thanks!

Yes, the build file was for Zig 0.10.

I've updated it for Zig 0.11. Note that you now need to use the zig build -Drelease command to get a release build.

Thank you!

pepa65 commented 1 year ago

Perhaps you'd like me to open a new issue for this, but if I do zig build -Drelease:

zig build-exe dsvpn Debug native: error: error(compilation): clang failed with stderr: In file included from /data/git/dsvpn/src/os.c:1:
In file included from /data/git/dsvpn/include/os.h:4:
/data/git/dsvpn/include/vpn.h:4:10: fatal error: 'sys/ioctl.h' file not found

error(compilation): clang failed with stderr: In file included from /data/git/dsvpn/src/vpn.c:1:
/data/git/dsvpn/include/vpn.h:4:10: fatal error: 'sys/ioctl.h' file not found

error(compilation): clang failed with stderr: /data/git/dsvpn/src/charm.c:2:10: fatal error: 'stdlib.h' file not found

zig build-exe dsvpn Debug native: error: the following command failed with 3 compilation errors:
/opt/zig/zig build-exe /data/git/dsvpn/src/charm.c /data/git/dsvpn/src/os.c /data/git/dsvpn/src/vpn.c --cache-dir /data/git/dsvpn/zig-cache --global-cache-dir /home/pp/.cache/zig --name dsvpn -I /data/git/dsvpn/include -D _GNU_SOURCE=1 --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install dsvpn transitive failure
   └─ zig build-exe dsvpn Debug native 3 errors
/data/git/dsvpn/src/os.c:1:1: error: unable to build C object: clang exited with code 1
/data/git/dsvpn/src/vpn.c:1:1: error: unable to build C object: clang exited with code 1
/data/git/dsvpn/src/charm.c:1:1: error: unable to build C object: clang exited with code 1

I'm guessing I am missing some dependency now..? I do have: libc6-dev:amd64: /usr/include/x86_64-linux-gnu/sys/ioctl.h and /usr/include/x86_64-linux-gnu/bits/stdlib.h

jedisct1 commented 1 year ago

Ah, sorry for that, I didn't try on linux.

Can you git pull and try again?

pepa65 commented 1 year ago

That does the trick! I'm guessing the -Drelease addition is just to optimize the build (and make it smaller)?

jedisct1 commented 1 year ago

Yes, it's going to be way smaller and faster with -Drelease.