Direction installing SDL on linux (ubuntu)

Hello all,
I am new to SDL and pretty new to linux. I am getting compile errors

-------------- Build: Debug in firstSDL (compiler: GNU GCC Compiler)---------------

g++ -o bin/Debug/firstSDL obj/Debug/main.o …/…/…/usr/lib64/ …/…/…/usr/lib64/ …/…/…/usr/lib64/
obj/Debug/main.o: In function `SDL::SDL(unsigned int)’:

/home/jrm/Documents/cprojects/firstSDL/main.cpp:52: undefined reference to SDL_CreateWindowAndRenderer' obj/Debug/main.o: In functionSDL::~SDL()’:
/home/jrm/Documents/cprojects/firstSDL/main.cpp:59: undefined reference to SDL_DestroyWindow' /home/jrm/Documents/cprojects/firstSDL/main.cpp:60: undefined reference toSDL_DestroyRenderer’
obj/Debug/main.o: In function SDL::draw()': /home/jrm/Documents/cprojects/firstSDL/main.cpp:67: undefined reference toSDL_SetRenderDrawColor’
/home/jrm/Documents/cprojects/firstSDL/main.cpp:68: undefined reference to SDL_RenderClear' /home/jrm/Documents/cprojects/firstSDL/main.cpp:71: undefined reference toSDL_RenderPresent’
/home/jrm/Documents/cprojects/firstSDL/main.cpp:89: undefined reference to SDL_SetRenderDrawColor' /home/jrm/Documents/cprojects/firstSDL/main.cpp:90: undefined reference toSDL_RenderFillRect’
/home/jrm/Documents/cprojects/firstSDL/main.cpp:91: undefined reference to `SDL_RenderPresent’
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
10 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I have installed SDL the linux way and all went fine. I am using Code:Blocks (most recent version 17.1)

I have pointed the linker to the following libraries,

I have included the SDL.h file via the code blocks include file dialog.

I have read up on using the sdl-config to help the compile but honestly did not figure out how that helps.

It seems like I am missing a library as it can not find some routines.

I am sure you experienced people are so tired of installation questions by now.

If someone could point me in the right directions it would be appreciated.


gcc -o myfirstSDL myfirstSDL.c sdl-config --cflags --libs

Looks like you’re trying to use SDL2, but are linking against SDL1.2 has tutorials
for setting up SDL2 for your project on different operating systems and
different IDEs, incl. Code Blocks on Linux

1 Like

Thank you Daniel,
I have it installed correctly and compiling. Thanks for that link.

Great, have fun with SDL! :slight_smile: