I’m using this tutorial page:
http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php
I downloaded the source code and tried to compile it unchanged. But I get an error message:
01_hello_SDL.cpp: In function ‘int main(int, char**)’:
01_hello_SDL.cpp:15:2: error: ‘SDL_Window’ was not declared in this scope
SDL_Window* window = NULL;
^~~~~~~~~~
etc…
I use xubuntu (I think 17.04) and have SDL installed (at least that’s what I think, becauseSDL header files are available).
What’s wrong?
Kind regards
Peter Wiehe
did you also copy the part with “#include <SDL.h>”?
Did you install the SDL2 development package?
It’s called libsdl2-dev on Ubuntu.
If you’ve done that, you should be able to compile your program with
g++ -Wall `sdl2-config --cflags` 01_hello_SDL.cpp `sdl2-config --libs` -o sdl2test
(the backticks around “sdl2-config --cflags” and “sdl2-config --libs” are important!)
sdl2-config --cflags
sets, amongst other things, the correct include-path (e.g. -I /usr/include/SDL2/
) and sdl2-config --libs
sets the library search dir and the lib to link against (sth like -L/usr/lib/x86_64-linux-gnu -lSDL2
)
I used ‘sdl-config…’ instead of 'sdl2-config…'
Now it works fine
Thanks
Peter