Course contentsShow
← C
Lesson 30 of 1,2191. FoundationsFree lesson

Creating an executable binary

Creating an executable binary

What you'll learn: How to transform your human-readable C code into a functional file that your computer can actually run.

From text to action

Computers are incredibly fast, but they are also quite literal. They don’t understand the English-like words used in C, such as int, main, or printf. To a computer’s processor, instructions must be delivered in a specific stream of ones and zeros known as machine code.

Think of your C source code like a handwritten recipe. You can read it and understand the steps, but the recipe itself isn’t a meal. The compiler is the chef that takes your instructions and performs the "work" to produce a finished dish—in this case, an executable binary.

Using the compiler

To bridge the gap between your text file and a running program, you use a tool called a compiler (like gcc or clang). When you run the compiler, it reads your .c file, checks for grammar errors, and translates it into a new file: the executable.

If you have a file named hello.c, you might run a command like this in your terminal:

// hello.c
#include <stdio.h>

int main() {
    printf("Hello, world!");
    return 0;
}

By typing gcc hello.c -o my_program, the compiler processes your text and creates a new file named my_program. Unlike your source code, you cannot read this new file in a text editor; it is a "binary" file meant strictly for the computer's eyes.

Why this matters

The reason we create an executable is portability and speed. Once the binary is created, you no longer need the C source code or the compiler to run the program. You can give that binary to a friend with the same operating system, and it will run instantly. The "translation" is already finished, so the computer can execute the instructions at lightning speed without having to figure out what you meant.

Key takeaway

Compilation is the act of translating human-readable C source code into a standalone binary file that the computer's processor can execute directly.