sdl2: Compiler throws "Undefined Reference" I'm trying to learn computer graphics, but when I tried to get this very simple windower running with c

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

#include &lt;SDL2/SDL.h&gt;

static const int width = 320;
static const int height = 180;

int main(int argc, char **argv)
{
    SDL_Init(SDL_INIT_VIDEO);

    SDL_Window *window = SDL_CreateWindow("Hello, SDL2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL);

    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}


I try to compile and...

vke@komputilo:~/dev/MiaLudo/source$ gcc -g main.c -o ../ludo
/tmp/ccfVU5ua.o: In function `main':
/home/vke/dev/MiaLudo/source/main.c:11: undefined reference to `SDL_Init'
/home/vke/dev/MiaLudo/source/main.c:13: undefined reference to `SDL_CreateWindow'
/home/vke/dev/MiaLudo/source/main.c:15: undefined reference to `SDL_DestroyWindow'
/home/vke/dev/MiaLudo/source/main.c:16: undefined reference to `SDL_Quit'
collect2: error: ld returned 1 exit status


Hoping someone can help me out, I'm running Trisquel Linux if that's important
The problem is definitely a lack of linker flags.
It can see that you want to include &lt;SDL/SDL2.h&gt;, which is a sort of promise that said functions contained in that header have been built and will be available; but when your linker looks to find the actual machine code, it needs a little more than the header. It needs the library itself.
For SDL2, you would usually use something like:
gcc -g main.c -o ../ludo -lSDL2

On Linux, this is more-or-less the same command, but for complete definitions it also instructs the compiler to look inside /usr/lib/x86_64-linux-gnu/libSDL2.a (or wherever it is on your system). Note that the lib prefix on the file name is assumed, and the extension is irrelevant.
Do that, and your program should compile. Note that some SDL extensions, like Image and Mixer, require their own libraries. An SDL-specific shortcut to ensure that you've got everything is to use the handy pkg-config, like so:
gcc -g main.c -o ../ludo $(pkg-config --cflags --libs sdl2)

Which will be interpreted by the terminal as
gcc -g main.c -o ../ludo -D_REENTRANT -I/usr/include/SDL2 -lSDL2

This is less generic however, a bit more paranoid, and a bit of a cheat; but perhaps it will help you.
The thing to remember with C is that a function needs to be declared to be used in code, and that's compiler-end; but to be built into an actual stand-alone program it also has to be defined, which is where the post-compiler linker comes in.