Skip to content

Latest commit

 

History

History
155 lines (105 loc) · 2.45 KB

File metadata and controls

155 lines (105 loc) · 2.45 KB

Setup

Before you start: what is compiling?

C is a compiled language.

  • You write source code (.c)
  • A compiler turns it into an executable program (here: quack)

That executable is what you run in the terminal.


What is make?

make is a build tool. It reads a file called Makefile.

Our Makefile tells make:

  • how to compile quack.c
  • which compiler flags to use
  • how to clean up compiled files

When you run:

make

It runs a command similar to:

gcc -std=c11 -Wall -Wextra -O2 -o quack quack.c

Meaning of flags:

  • -std=c11 : use the C11 standard
  • -Wall -Wextra : show useful warnings
  • -O2 : enable optimization

Setup instructions (Windows / macOS / Linux)

Choose your operating system and follow the steps.


Windows (recommended: WSL)

The smoothest way to do C on Windows is WSL (Windows Subsystem for Linux). This gives you a real Linux terminal with gcc and make.

Step 1 - Install WSL + Ubuntu

  1. Open PowerShell as Administrator
  2. Run:
wsl --install
  1. Restart if asked
  2. Open Ubuntu from the Start Menu and finish setup (create username/password)

Step 2 - Install build tools inside Ubuntu

In the Ubuntu terminal:

sudo apt update
sudo apt install build-essential

This installs:

  • gcc (C compiler)
  • make (build tool)

Step 3 - Build Quack

Go to the project folder (in WSL) and run:

make

Step 4 - Run a program

./quack run programs/sum10.duck

Windows (alternative: MSYS2) - optional

If you cannot use WSL, MSYS2 also works, though the setup is more involved. WSL is the preferred path.


macOS

Step 1 - Install Xcode Command Line Tools

Open Terminal and run:

xcode-select --install

This installs clang (a C compiler) and make.

Step 2 - Build

In the project folder:

make

Step 3 - Run

./quack run programs/sum10.duck

Linux (Ubuntu/Debian)

Step 1 - Install compiler + make

sudo apt update
sudo apt install build-essential

Step 2 - Build

make

Step 3 - Run

./quack run programs/sum10.duck

Troubleshooting

"command not found: make" or "gcc not found"

You don't have build tools installed. Follow the setup steps above for your OS.

"Permission denied" when running ./quack

Run:

chmod +x quack

(Usually not needed, but sometimes happens if files moved oddly.)