xmake-zig
/xmake-zig
Buduje projekty Zig w xmake: pliki binarne i biblioteki, kompilację krzyżową oraz współpracę Zig z C.
- Autor
- xmake-io ↗
- Repozytorium
- xmake-skills ↗
- Licencja
- Apache-2.0
- Ostatnia zmiana repozytorium
- 24.08.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 24.08.2026, bez odwołań do wycofanych modeli i API.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
Co robi i kiedy
Buduje projekty Zig w xmake: pliki binarne i biblioteki, kompilację krzyżową oraz współpracę Zig z C.
Oryginalny opis (EN)
Use when building Zig projects with xmake — binary/library targets with `.zig` sources, cross-compilation (one of Zig's strengths), and mixing Zig with C.
Jak działa
- 1. Minimal project
- 2. Target kinds
- 3. Toolchain
- 4. Cross-compile
- 5. Mixing Zig with C
- 6. Using Zig as your C compiler
- Pitfalls
- When to branch out
Podgląd SKILL.md
---
name: xmake-zig
description: Use when building Zig projects with xmake — binary/library targets with `.zig` sources, cross-compilation (one of Zig's strengths), and mixing Zig with C.
---
# Building Zig with Xmake
Xmake drives `zig build-exe` / `zig build-lib` under the hood. Zig is particularly nice because its native cross-compile story plays well with xmake's toolchain selection.
## 1. Minimal project
```bash
xmake create -l zig -t console hello
cd hello
xmake run
```
```lua
add_rules("mode.debug", "mode.release")
target("hello")
set_kind("binary")
add_files("src/*.zig")
```
## 2. Target kinds
```lua
target("app") set_kind("binary")
target("mylib") set_kind("static")
target("mydyn") set_kind("shared")
```
## 3. Toolchain
```bash
xmake f --toolchain=zig
xmake f --toolchain=zig --sdk=/opt/zig-0.12
```
Zig is auto-detected when `zig` is on PATH. Pin with `--sdk` for a specific install.
## 4. Cross-compile
Zig has built-in cross-compile for every target it supports — no extra SDK needed:
```bash
xmake f -p windows -a x86_64 --toolchain=zig
xmake f -p linux -a arm64 --toolchain=zig
xmake f -p macosx -a arm64 --toolchain=zig
xmake
```
Xmake passes `-target <triple>` to `zig build-exe`. Far easier than GCC/Clang cross-SDKs.
## 5. Mixing Zig with C
Zig ships its own C compiler (`zig cc`) that can build C files. You can mix them in one target:
```lua
target("app")
set_kind("binary")
add_files("src/main.zig", "src/helper.c")
add_includedirs("include")
```
Zig imports C via `@cImport`. No bridging needed.
## 6. Using Zig as your C compiler
Bonus trick: point xmake's C toolchain at `zig cc` for free cross-compile of C projects:
```bash
xmake f --toolchain=zig
xmake f --cc="zig cc" --cxx="zig c++"
```
This is especially useful for MinGW-free Windows builds from Linux.
## Pitfalls
- **Zig API churn.** Zig is pre-1.0; `build-exe` / `build-lib` flags change between versions. Pin `--sdk` to a known version in CI.
- **Mixing `.zig` and `.cpp` in one target.** `.zig` + `.c` is fine; C++ is more brittle — use a separate target with `add_deps`.
- **Runtime dependencies.** `-target <triple>` gives you a cross-compile, but you still need the right dynamic linker at runtime on the target — Zig can produce static binaries if you prefer (`-fno-pie` etc.).
## When to branch out
- Cross-compile plumbing (`-p`, `-a`, `--sdk`) → `xmake-cross-compilation`
- Target basics → `xmake-targets`
Wersje
W bazie nie ma innych skilli o nazwie xmake-zig.
Migawka bazy z 13.11.2026 · wersja paczki 9399f818027b (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100xmake-go
Buduje projekty Go w xmake: pliki binarne i biblioteki, moduły Go, kompilację krzyżową i współpracę z C przez cgo. - 100xmake-zigcc
Kompiluje C i C++ przez zig cc w xmake, także krzyżowo na inne platformy, z doborem krotki -target. - 96zig-best-practices
Wspiera czytanie i pisanie plików Zig: .zig, build.zig i build.zig.zon. - 100zig
Prowadzi przez język Zig: pisanie kodu, zakładanie projektów, migracje między wersjami i przegląd przepływów pracy. - 100zig-cross
Pomaga kompilować programy Zig na inne platformy: systemy wbudowane, WASM, Windows i ARM, także zig cc bez osobnego toolchainu. - 95zig
Implementuje, debuguje, przegląda, migruje i optymalizuje kod w Zig oraz systemy budowania.