Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2025/26/2
* archívum


Linkek

* kalendárium
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C#
* D lang.
* Java
* Nim
* Nim2
  + exercises
* XC=BASIC
* old
  ◇C++, ◇Clojure, ◇Scala


[ edit | logout ]
[ sandbox | passwd ]

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. zig cc is built on top of Clang.

Installation

Under 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

zig cc can do 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

Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2026 April 17, 19:05