|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
Compiling a C program with zig"Zig is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software." Why is it interesting for us? Zig can compile C codes and the command "zig cc" can be used as a drop-in replacement for GCC/Clang. InstallationUnder Manjaro Linux just install the package "zig" with your package manager. For Windows, consult the pages https://ziglang.org/download/ and https://ziglang.org/learn/getting-started/#managers . Compilation
$ cat main.c
#include <stdio.h>
int main()
{
printf("hello\n");
return 0;
}
$ gcc main.c
$ ./a.out
hello
$ zig cc main.c
$ ./a.out
hello
Cross-Compilation
On Linux, build a Windows EXE: $ zig cc main.c -target x86_64-windows $ wine a.exe hello 𝥶Or, just copy the resulting "a.exe" to Windows and execute it. It'll work. On Windows, build a Linux executable: C:\> zig cc main.c -target x86_64-linux-gnu 𝥶Copy the resulting "a.out" to Linux and launch it. It'll work. Links |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |