I'm currently trying to make a simple game with SDL and Box2D. Unfortunately, the code I added to make the character shoot proyectiles is so buggy I can't even begin to count the errors. To deal with this I added some code to show some debug info in the game. Unfortunately, after dealing with all the errors a weird error that didn't appear before popped up:
/usr/include/SDL/SDL_image.h|34|error: expected initializer before ‘extern’|
||=== Build finished: 1 errors, 0 warnings ===|
The code in SDL_image.h that causes this is:
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
I have no idea what causes this error message to appear, or how to solve this. There are no error messages on my code. I don't think there's anything wrong with the library because other game I did compiles just file. This is the only error that pops up.
You need to install SDL_image library like mentioned in the other answers, if you are on a Debian based systems you can simply install with the following command: In the third tutorial of lazyfoo is completely explained. Basically, you must add "-lSDL_image" to the compilation line.
SDL library in C/C++ with examples. SDL is Simple DirectMedia Layer.It is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.It can be used to make animations and video games.
It's not shipped with SDL. For those who are using SDL2, the file name has changed to "SDL2_image.h". See documentation: wiki.libsdl.org/MigrationGuide#line-435
Have a look at the end of the header files that are included before this one. My guess is that there's a missing ;
after a class definition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With