IDE & Environment Setup Guide¶
This guide explains how to set up a robust development environment for Suckless OGL, focusing on modern C tooling (clangd, CMake) and compatibility with containerized workflows like Distrobox.
1. Prerequisites¶
Essential Tools¶
- CMake (3.14+)
- Clang / GCC (C11 support)
- Make or Ninja
- clangd (Language Server)
Recommended Editor¶
VS Code is highly recommended for its excellent clangd integration.
- Install the clangd extension (llvm-vs-code-extensions.vscode-clangd).
- Optional: CodeLLDB for debugging (vadimcn.vscode-lldb).
2. The Setup Architecture¶
This project uses a hybrid build approach to ensure headers are visible to both the build system (inside Distrobox/Docker) and your IDE (on the Host).
Key Components¶
- CMake FetchContent: We force
FetchContentfor third-party libraries (like GLFW) instead of using system packages (pkg-config).- Why? This downloads sources into
build/_deps/, ensuring headers are physically present in the project folder.
- Why? This downloads sources into
- Compilation Database: We generate
compile_commands.jsonwhich tellsclangdexactly where to look for headers.
3. Configuration Steps¶
Step 1: Generate Compilation Database¶
Run this command once (or whenever you add new CMake targets). It works inside Distrobox or on a native Debian/Linux system.
# Clean build (optional but recommended for fresh setup)
rm -rf build/
# Configure and generate compile_commands.json
# Note: We configure in 'build/' but link the JSON to root for clangd
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# Create symlink for clangd
ln -sf build/compile_commands.json compile_commands.json
What this does:
- Downloads GLFW, cglm, stb, etc. into build/_deps/.
- Generates build/compile_commands.json with absolute paths to those headers.
- Links it to the root so your editor finds it.
Step 2: VS Code Configuration¶
If you haven't already, accept the workspace recommendation to install clangd.
- Open the project in VS Code.
- If prompted, Disable IntelliSense for the Microsoft C/C++ extension (to allow
clangdto take over). - Open
src/main.c. You should be able to Ctrl+Click on functions likeglfwInitorapp_run.
4. Troubleshooting¶
Headers not found (red squiggles)¶
If clangd reports missing headers despite the build working:
- Check for
compile_commands.json: Ensure the symlink exists in the project root. - Verify Include Paths: Open
compile_commands.jsonand search for-I.../build/_deps/glfw-src/include. If it's missing, re-runcmake -B build. - Reload Window: VS Code sometimes caches old paths. run
Ctrl+Shift+P->Developer: Reload Window. - Rebuild:
Distrobox vs Host Paths¶
If you build inside a container but edit on the host:
- The Fix: Our CMakeLists.txt forces local dependency builds (FetchContent). This avoids the issue where pkg-config points to /usr/include inside the container (which doesn't exist on the host).
- Validation: Ensure you DO NOT use system-installed GLFW dev packages for the build configuration if you want IDE completions to work perfectly on the host.
5. Debian / Native Linux Compatibility¶
This setup is fully compatible with Debian 13 or any other distro without Distrobox. - Requirement: You need X11 development headers installed system-wide, as GLFW compiles from source.