#How to build an executable for an ubuntu machine while on a Mac?
1 messages · Page 1 of 1 (latest)
zig build -Dtarget=x86_64-linux-none
thank you! how would i need to update my build.zig to accommodate -Dtarget=x86_64-linux-none?
when i run the above i get
joneric.cook@MBP zest % zig build -Dtarget=x86_64-linux-none
error: Invalid option: -Dtarget
Usage: /usr/local/Cellar/zig/0.10.1/bin/zig build [steps] [options]
going to try out this https://ziglang.org/documentation/0.10.1/#Building-an-Executable
dang - i get this error
joneric.cook@MBP zest % zig build example -Dexample=scouter -Dtarget=x86_64-linux-none
/Users/joneric.cook/github/zest/zig-out/bin/scouter: /Users/joneric.cook/github/zest/zig-out/bin/scouter: cannot execute binary file
The following command exited with error code 126 (expected 0):
cd /Users/joneric.cook/github/zest && /Users/joneric.cook/github/zest/zig-out/bin/scouter
error: UnexpectedExitCode
/usr/local/Cellar/zig/0.10.1/lib/zig/std/build/RunStep.zig:277:17: 0x10b8987dc in runCommand (build)
return error.UnexpectedExitCode;
^
/usr/local/Cellar/zig/0.10.1/lib/zig/std/build/RunStep.zig:183:5: 0x10b871af4 in make (build)
try runCommand(
^
/usr/local/Cellar/zig/0.10.1/lib/zig/std/build.zig:3653:9: 0x10b7fdb4b in make (build)
try self.makeFn(self);
^
/usr/local/Cellar/zig/0.10.1/lib/zig/std/build.zig:510:9: 0x10b7e6ecd in makeOneStep (build)
try s.make();
^
/usr/local/Cellar/zig/0.10.1/lib/zig/std/build.zig:504:17: 0x10b7e6e27 in makeOneStep (build)
return err;
^
/usr/local/Cellar/zig/0.10.1/lib/zig/std/build.zig:465:13: 0x10b7e6a68 in make (build)
try self.makeOneStep(s);
^
/usr/local/Cellar/zig/0.10.1/lib/zig/build_runner.zig:225:21: 0x10b7ea219 in main (build)
else => return err,
^
error: the following build command failed with exit code 1:
/Users/joneric.cook/github/zest/zig-cache/o/a09344cc2c951018db7f3158496aec49/build /usr/local/Cellar/zig/0.10.1/bin/zig /Users/joneric.cook/github/zest /Users/joneric.cook/github/zest/zig-cache /Users/joneric.cook/.cache/zig example -Dexample=scouter -Dtarget=x86_64-linux-none
How to build an executable for an ubuntu machine while on Mac?
How to build an executable for an ubuntu machine while on a Mac?
This means it's working
If you look at the error, it's erroring when trying to run the resulting executable
Which is obviously going to happen when you try to run a Linux binary on macOS
Depends on how your build.zig works
Currently you've got a RunStep in there somewhere, you just need to not do that
💯
-none isnt a valid abi on linux
From a quick glance at your build.zig in the zest repo, just remove the example arg
you can leave it off or pass -musl since you're cross compiling
Yes it is
The default is -none
So it's optional
But it is valid
the default is -gnu
what
If you're compiling on a glibc system, the default target will be -gnu yes, but if you're specifying the target explicitly, it's not
the code is all here by the way https://github.com/ziglabs/zest
just doing zig build -Dtarget=x86_64-linux-none works - it just builds and thats it
thanks for the help!
We're both wrong :)
The default for cross-compiling is musl