SDL2 Setup for Eclipse C++ IDE

For all of the users that get a cacophony of ‘undefined reference’ errors when starting to use SDL2 in an IDE: this will likely fix most/all problems.

Under Properties>C/C++ Build>Settings
    Add '/usr/include/SDL2' to the Includes folders for the compilers
    Make sure 'SDL2' is present in Libraries for the Linker

Under Properties>C/C++ General>Paths and Symbols
    Add 'SDL2' to the Libraries Tab

What is off-putting is that even though SDL is a header-only library (not having any .so/.dll files): the IDE still wants you to add the names of the libraries in order to set everything up correctly, so it’s very counter-intuitive for non-programmers.

Although this may seem trivial to many, there aren’t any tutorials on setting up Eclipse for working with SDL and this might be a lifesaver for beginners looking to get into programming.

I also made and uploaded a quick YouTube video right after I found the solution.

SDL isn’t a header-only library. What have you that impression? The reason adding SDL to the library list fixed it is the indicator that there is indeed so/DLL files.

Found it! It was stored in a bit of an obscure location, /usr/lib/x86_64-linux-gnu/, which is why I didn’t see it when looking through /lib and /usr/lib. Sorry about that.

On my previous OS (Manjaro): SDL was usually under /usr/lib. Debian has its own, sometimes annoying, way of doing things.

1 Like