Simple example won't run

Hello everyone!

I’m trying to run a simple C++ example using the SDL library. I get a bunch of weird errors that I don’t know how to fix. An attempt to google the error did not work.

Code here. I’m trying to compile this code with this command : g++ 01_hello_SDL.cpp -w -lSDL2 -o 01_hello_SDL
Errors here.

Maybe someone else had the same problem? Or does anyone know how to fix this?

Thank you in advance!

Here you have examples how to look at the compilation command:

On LazyFoo, something about it is …

I exactly took an example from LazyFoo, I compile as they indicate.

use pkg-config pkg-config --cflags --libs sdl2 or sdl2-config sdl2-config --cflags --libs. Example command: g++ 01_hello_SDL.cpp -lSDL2 -o 01_hello_SDL $(sdl2-config --cflags --libs) .
If it still doesn’t work, you could try using locate to see where the libraries are installed and add the directory using the -L flag for the compiler.

Note: if the issue still persists, telling us what distro you use and how you installed the libraries might help us to figure out the problem .