diff options
-rw-r--r-- | example-cross-compile/.gitignore | 5 | ||||
-rw-r--r-- | example-cross-compile/Makefile | 17 | ||||
-rw-r--r-- | example-cross-compile/lin.zig | 5 | ||||
-rw-r--r-- | example-cross-compile/win.zig | 8 |
4 files changed, 35 insertions, 0 deletions
diff --git a/example-cross-compile/.gitignore b/example-cross-compile/.gitignore new file mode 100644 index 0000000..3fd3ba4 --- /dev/null +++ b/example-cross-compile/.gitignore @@ -0,0 +1,5 @@ +*.exe +*.exe.obj +*.pdb +*.elf +*.elf.o diff --git a/example-cross-compile/Makefile b/example-cross-compile/Makefile new file mode 100644 index 0000000..72f611d --- /dev/null +++ b/example-cross-compile/Makefile @@ -0,0 +1,17 @@ +riscv64: lin-riscv64 +aarch64: lin-aarch64 +mips64el: lin-mips64el + +lin-%: + zig build-exe lin.zig -target $*-linux-musl --name $*.elf + file $*.elf + qemu-$* $*.elf + +win: + zig build-exe win.zig -target x86_64-windows -lc + file win.exe + wine win.exe + +clean: + git clean -fdx . + diff --git a/example-cross-compile/lin.zig b/example-cross-compile/lin.zig new file mode 100644 index 0000000..9eb2ee8 --- /dev/null +++ b/example-cross-compile/lin.zig @@ -0,0 +1,5 @@ +const print = @import("std").debug.print; + +pub fn main() void { + print("hello from zig main()\n", .{}); +} diff --git a/example-cross-compile/win.zig b/example-cross-compile/win.zig new file mode 100644 index 0000000..200fa34 --- /dev/null +++ b/example-cross-compile/win.zig @@ -0,0 +1,8 @@ +const winh = @cImport({ + @cInclude("windows.h"); + @cInclude("winuser.h"); +}); + +pub fn main() void { + _ = winh.MessageBoxA(null, "world", "hello", 0); +} |