0PricingLogin
Zig Academy · Lesson

Calling C Functions and Linking

Bind to libc and external libraries.

Importing Is Not Linking

@cImport gives you the declarations, but the actual machine code still lives in a C library you must link against.

Link Against libc

Most C calls need the C standard library. Tell the build to link libc so functions like printf resolve at link time.

exe.linkLibC();

All lessons in this course

  1. Import C Headers with @cImport
  2. Calling C Functions and Linking
  3. C Pointers, Strings, and Types
  4. zig translate-c to Read C as Zig
← Back to Zig Academy