Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Setting Up  ›  Lesson

Installing a C Compiler

Installing C 10 minInstalling C means installing a toolchain such as GCC or Clang, using your system's package manager, and confirming it works with a version check.

Installing a C Compiler

You have written the first line of the greenhouse logger, but the processor cannot read C. Before anything runs, something has to translate your text into machine code. Setting up C is really setting up that translator.

The rule

You don't install C — you install a compiler that speaks it.

C itself is a standard, a document published by ISO. What you install is a toolchain: a compiler, an assembler, a linker, and the headers and library files of the C standard library. The three toolchains you will meet most:

  • GCC, the GNU Compiler Collection, standard on most Linux systems
  • Clang, part of the LLVM project, standard on macOS
  • MSVC, Microsoft's compiler, installed with Visual Studio on Windows

How to get one on each system:

# Debian or Ubuntu: GCC, make and the C library headers
sudo apt install build-essential

# Fedora
sudo dnf install gcc

# macOS: the Xcode command-line tools, which include Clang
xcode-select --install

# Windows, inside the MSYS2 terminal
pacman -S mingw-w64-ucrt-x86_64-gcc

On Windows you can also install Visual Studio with its "Desktop development with C++" workload (MSVC handles C too), or use WSL to get a full Linux environment.

On macOS, typing gcc actually runs Clang. Apple sets it up that way so that build scripts expecting gcc still work.

Finally, tell the compiler which version of the language you mean. Default versions differ between compilers and even between releases of the same compiler, so this course builds with an explicit flag:

gcc -std=c17 -Wall -Wextra logger.c

-std=c17 checks your code against C17. -Wall -Wextra switch on the most useful warnings. Despite its name, -Wall does not enable every warning, which is why -Wextra comes along. Clang accepts the same flags, so the command works whichever compiler you ended up with.

The shortcut

Three moves, always in this order: pick, install, prove.

Setting up an Ubuntu laptopStep 1 of 4
  1. Pick

    Ubuntu is Linux, and GCC is the usual compiler there.

The common mistake is jumping straight to an editor, installing a C extension, and wondering why nothing builds. An editor is not a compiler, and prove comes before anything else.

Drills

Answer fast — trust the rule.

quick drill

On macOS, after xcode-select --install, which compiler runs when you type gcc?

quick drill

Which Ubuntu package brings GCC, make and the C library headers in one go?

quick drill

What is the quickest proof that the compiler is installed and on your PATH?

quick drill

Why pass -std=c17 when compiling?

Remember

  • You don't install C — you install a compiler toolchain: GCC, Clang or MSVC.
  • Shortcut: pick, install with the system package manager, prove with --version.
  • Trap: an editor extension is not a compiler. Name the standard with -std=c17.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainGetting a classmate set up

A classmate on Windows and another on macOS both want to build the greenhouse logger. Explain what each should install, how they can check it worked, and why you suggest building with -std=c17.