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.
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:
makeIt runs a command similar to:
gcc -std=c11 -Wall -Wextra -O2 -o quack quack.cMeaning of flags:
-std=c11: use the C11 standard-Wall -Wextra: show useful warnings-O2: enable optimization
Choose your operating system and follow the steps.
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.
- Open PowerShell as Administrator
- Run:
wsl --install- Restart if asked
- Open Ubuntu from the Start Menu and finish setup (create username/password)
In the Ubuntu terminal:
sudo apt update
sudo apt install build-essentialThis installs:
gcc(C compiler)make(build tool)
Go to the project folder (in WSL) and run:
make./quack run programs/sum10.duckIf you cannot use WSL, MSYS2 also works, though the setup is more involved. WSL is the preferred path.
Open Terminal and run:
xcode-select --installThis installs clang (a C compiler) and make.
In the project folder:
make./quack run programs/sum10.ducksudo apt update
sudo apt install build-essentialmake./quack run programs/sum10.duckYou don't have build tools installed. Follow the setup steps above for your OS.
Run:
chmod +x quack(Usually not needed, but sometimes happens if files moved oddly.)