0Pricing
Zig Academy · 강의

대상과 -target 트리플

OS, 아키텍처, ABI를 지정합니다.

대상과 -target 트리플은(는) CoddyKit의 무료 Zig Academy 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Zig Academy 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Zig Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Cross-Compiling Is Built In

Zig ships every supported target inside the compiler, so cross-compilation needs no extra toolchains or downloads to begin.

The Target Triple

You name a target with a triple: it spells out the CPU architecture, the operating system, and the ABI in one string.

x86_64-linux-gnu

Three Parts, One String

Read a triple left to right as arch-os-abi. Each part narrows down exactly which binary the compiler should produce.

aarch64-macos-none

Pass It with -target

You select a target on the command line with the -target flag, and Zig builds for that machine instead of your own.

zig build-exe main.zig -target aarch64-linux-musl

The Architecture Part

The first field is the architecture, like x86_64, aarch64, or riscv64. It decides the instruction set of the output.

The OS Part

The middle field is the operating system, such as linux, macos, or windows. It shapes system calls and file formats.

The ABI Part

The last field is the ABI, like gnu, musl, or msvc. It picks the C library and calling conventions to match.

List Every Target

Not sure which triples exist? Ask Zig to print them all. zig targets dumps the supported architectures, OSes, and ABIs.

zig targets

Your Native Target

With no -target flag, Zig builds for the native triple: the same arch, OS, and ABI as the machine you are on.

Omitting Parts

You can leave fields off and Zig fills in a sensible default. x86_64-linux works because the ABI is chosen for you.

zig build-exe main.zig -target x86_64-linux

Tune the CPU Model

You can refine the architecture with a CPU model after a plus sign, asking Zig to use features of a specific processor.

zig build-exe main.zig -target x86_64-linux -mcpu=baseline

Quick Check

Recall the order of fields inside a target triple.

Recap

You learned that a target triple names arch, OS, and ABI, and that -target lets Zig build for any of them. 🌍

자주 묻는 질문

“대상과 -target 트리플” 강의는 무료인가요?

네 — “대상과 -target 트리플” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Zig Academy 강의 전체를 잠금 해제할 수 있습니다. Zig Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

“대상과 -target 트리플”에서 뭘 배우나요?

OS, 아키텍처, ABI를 지정합니다. 브라우저에서 직접 실행하는 실습 코드로 Zig Academy을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Zig Academy을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Zig Academy은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“대상과 -target 트리플” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Zig Academy 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Zig Academy 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 대상과 -target 트리플
  2. Linux, macOS, Windows용 빌드
  3. zig cc로 C 크로스 컴파일하기
  4. 정적 바이너리와 musl
← Zig Academy(으)로 돌아가기