الأهداف وثلاثية -target
حدّد نظام التشغيل والمعمارية وABI
الأهداف وثلاثية -target درس مجاني في Zig Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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-gnuThree 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-nonePass 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-muslThe 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 targetsYour 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-linuxTune 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=baselineQuick 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) وفتح باقي دورة Zig Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Zig Academy 4 دروس في المجموع.
ماذا ستتعلم في «الأهداف وثلاثية -target»؟
حدّد نظام التشغيل والمعمارية وABI تتمرن على Zig Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Zig Academy؟
لا تُشترط خبرة سابقة. Zig Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «الأهداف وثلاثية -target»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Zig Academy هذا؟
نعم. كل درس في Zig Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- الأهداف وثلاثية -target
- البناء لـ Linux وmacOS وWindows
- الترجمة المتقاطعة لـ C باستخدام zig cc
- الملفات التنفيذية الساكنة وmusl