Unable to debug a c project that was built inside the build folder

Author: scrytheCreated Sep 20, 2026Updated Sep 21, 2026
LabelsBugDebuggerLinux

If I build a project within the build folder, I'm unable to debug the file then. As an example:

bash
clang -g -O0 -DBUILD_DEBUG=1 -o simple_test ../src/simple_test.c

If I then set a breakpoint somewhere, it doesn't work. Compared to building it outside of the build directory, without having to use ../ to locate the source file:

clang -g -O0 -DBUILD_DEBUG=1 -o build/simple_test src/simple_test.c

Here it works.

This is not really a big problem since I can just build it outside of the directory, but it works with gdb so I figured this is an issue.

I'm running Cachyos (Arch Fork, Linux) with Hyprland.