Question

I installed SDL2 in Ubuntu, and I've been having trouble getting the sample program that comes with it to work. Here are the errors that appear.

|In function ‘int main(int, char**)’:|
‘SDL_HWSURFACE’ was not declared in this scope|
‘SDL_DOUBLEBUF’ was not declared in this scope|
‘SDL_SetVideoMode’ was not declared in this scope|
‘SDL_Flip’ was not declared in this scope|
||=== Build finished: 4 errors, 0 warnings ===|

Here is my header (I added SDL_image in case there were some issues, but it didn't change anything).

#ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
#endif
#ifdef __APPLE__
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif
#ifdef _SDL_imageH
#include <SDL_image.h>
#endif

Here are the libraries I included in the linker settings:

libSDL2.a
libSDL2main.a
libSDL2_image.a
libz.a

I added on those libraries consecutively, but none of them seemed to help my program run. Below are the other linker options:

-lmingw32
-lSDL2main
-lSDL2
-mwindows
-lm
-ldinput8
-ldxguid
-ldxerr8
-luser32
-lgdi32
-lwinmm
-limm32
-lole32
-loleaut32
-lshell32 -lversion -luuid -static-libgcc

I also included in the compiler search directories /usr/local/include/SDL2.

I also tried -lmingw64 as I have a 64-bit compiler, although I don't know whether or not that option is available to me, but I suspect my compiler may be the problem.

Another issue is that when I run grep -r SDL_HWSURFACE /usr/ none of the files in the directory (or other directories I've searched) have that text other than the main.cpp file that is used to generate the test sample.

The location of the first two errors are in this line

SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16,
                                       SDL_HWSURFACE|SDL_DOUBLEBUF);

although I don't think that is extremely relevant.

Was it helpful?

Solution

SDL_SetVideoMode, as well as many other things, belongs to SDL 1.2 and no longer exists in SDL2. Please read https://wiki.libsdl.org/MigrationGuide

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top