Chapter 00: Setup & Toolchain

Install GCC, Make, SDL 1.2 headers, and clangd on Linux Mint, then verify VSCodium autocomplete and the project layout.

Chapter:00    Duration: 20 min
Files:Makefile, compile_flags.txt
Concepts:ISO C89 flags, SDL 1.2 headers, clangd, Flatpak sandbox paths
On this page:Packages · Project Tree · Makefile · VSCodium + clangd · Exercises · Recap

1. Installing Packages on Linux Mint

Open a terminal and install the C compiler, Make, SDL 1.2 development headers, and the clangd language server:

Terminal (bash)
sudo apt update
sudo apt install build-essential libsdl1.2-dev clangd

2. Project Directory Layout

Keep the repository flat and predictable. Every `.c` and `.h` file lives inside src/, while build files sit in the root pshot/ directory:

Directory Tree (text)
pshot/
  Makefile
  compile_flags.txt
  src/
    types.h
    platform.h
    platform.c
    main.c

3. The Strict ISO C89 Makefile

We compile with -std=c89 -Wall -Wextra -pedantic so modern GCC catches any C99/GNU extension that would break older compilers or retro Windows toolchains. Notice $(OBJS) in the clean rule so object files are always wiped cleanly.

Makefile (makefile)
CC      = gcc
CFLAGS  = -std=c89 -Wall -Wextra -pedantic -Wno-long-long -O2 -Isrc $(shell sdl-config --cflags)
LDFLAGS = $(shell sdl-config --libs) -lm

TARGET  = pshot
SRCS    = src/main.c src/platform.c
OBJS    = $(SRCS:.c=.o)

all: $(TARGET)

$(TARGET): $(OBJS)
	$(CC) $(OBJS) -o $(TARGET) $(LDFLAGS)

src/%.o: src/%.c
	$(CC) $(CFLAGS) -c $< -o $@

run: $(TARGET)
	./$(TARGET)

clean:
	rm -f $(OBJS) $(TARGET)

.PHONY: all run clean
Pitfall: Spaces vs. Tabs in Makefile
Make requires literal TAB characters before recipe lines (such as $(CC) ...). If you see missing separator, switch VSCodium’s bottom-right indicator from Spaces: 4 to Indent Using Tabs while editing Makefile.

4. Hooking Up VSCodium & clangd

Install the clangd extension (by llvm-vs-code-extensions) from Open VSX inside VSCodium, then place compile_flags.txt in your project root right next to Makefile:

compile_flags.txt (text)
-std=c89
-Wall
-Wextra
-pedantic
-Isrc
-I/usr/include/SDL
-D_GNU_SOURCE=1
-D_REENTRANT
Pitfall: Flatpak VSCodium Header Paths
If VSCodium was installed via Linux Mint’s Software Manager as a Flatpak, host headers are mounted under /run/host/usr/include instead of /usr/include. Change the include line in compile_flags.txt to -I/run/host/usr/include/SDL and run clangd: Restart language server from the Command Palette.

Exercises

Recap