DevC++ with SDL_image problams

Started by
17 comments, last by Drew_Benton 19 years ago
I have been working on a chess game (very very simple since its my first game) on linux using SDL and SDL_image, and i wanted to port it to windows. so i installed DevC++ 4.9.9.2, and it worked great. so i went to DevPack's and downloaded all the libraries needed. this is how the package manager looked after all the libraries installed. so i made a new SDL project, and example code worked fine. so i tried to put my chess game code (which worked fine when compiling in linux) along with SDL_image. Code and it gives this following list of errors: 8 C:\Dev-Cpp\include\SDL\SDL.h:34, from SDLchess.c In file included from C:/Dev-Cpp/include/SDL/SDL.h:34,from SDLchess.c 69 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 69 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 69 C:\Dev-Cpp\include\SDL\SDL_image.h [Warning] data definition has no type or storage class 71 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 71 C:\Dev-Cpp\include\SDL\SDL_image.h [Warning] data definition has no type or storage class 72 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 72 C:\Dev-Cpp\include\SDL\SDL_image.h [Warning] data definition has no type or storage class 80 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 81 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 82 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 83 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 84 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 85 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 86 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 87 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 88 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token 89 C:\Dev-Cpp\include\SDL\SDL_image.h syntax error before '*' token and it goes on and on for another 50 lines like this. what is the problam ? (and if someone wants me to try a simple example code and tell him if i get any errors, then i will do it if he asks) Any reply will be welcome.
Advertisement
up
In your code I saw that you had this line:
#include <SDL/SDL.h> /* already included SDL_image.h inside SDL.h */
Now did you put SDL_Image.h inside the SDL.h file? It should not be in the SDL.h file due to dependecies - it needs to appear like this:
#include <SDL/SDL.h>
#include <SDL/SDL_Image.h> That is my first suggestion/question [smile] Oh and you should wait at least 6 hours before a bump [wink], just a pointer.
so this was the SDL.h file when i included the SDL_image.h in it:

#include "SDL_main.h"
#include "SDL_image.h"
#include "SDL_types.h"
#include "SDL_getenv.h"
#include "SDL_error.h"
#include "SDL_rwops.h"
#include "SDL_timer.h"
#include "SDL_audio.h"
#include "SDL_cdrom.h"
#include "SDL_joystick.h"
#include "SDL_events.h"
#include "SDL_video.h"
#include "SDL_byteorder.h"
#include "SDL_version.h"

so ive deleted that line and now it looks just like before.

so now i added #include <SDL/SDL_image.h> to my updated code (after removing it from SDL.h) and tried to compile, and this is the compiler output:

[Linker error] undefined reference to `IMG_Load'
[Linker error] undefined reference to `IMG_Load'
[Linker error] undefined reference to `IMG_Load'
[Linker error] undefined reference to `IMG_Load'
[Linker error] undefined reference to `IMG_Load'
more undefined references to `IMG_Load' follow
ld returned 1 exit status
C:\Documents and Settings\dean\My Documents\SDLchess\Makefile.win [Build Error] [SDLchess.exe] Error 1
Now you will need to link in SDL_Image. To do that you can go to Project->Project Options->Parameters->Linker. In that box it should look similar to this:
-lmingw32-lsdlmain-lsdl-lSDL_Image
okay, so i added the -lSDL_Image into the linker and it gives me the following error:

Then that means you have incompatible versions of SDL and it's libraries. The problem is that you will need to get a version of SDL that matches. The libraries you are using for SDL_Image, since that version is not the most recent for it is a Dev-Pak. I tried to use SDL 1.2.8 as well as all the 'recent' stuff, but it was missing a version of Libpng, so you will need to find out which ones are the compatible with each other. Alos, how did you get it to compile, your main function has to be: int main( int argc, char* argv[] ) - have you already made that change?
yes i already added th proper main function.
and what do you mean by "incompatible", that i should try diffrent versions of SDL with diffrent versions of SDL_image ?
Never mind on that I was missing a dll file that I found here here. You should have evreything that you need, excluding that .dll probabally, not sure. Does yours compile and run? I just added in my own files and it works fine [smile].
oh ya, you have to include all the jpeg png and tiff dll with the project.
after i put all the dll's with the project it gave me the error i put 4 posts ago.

This topic is closed to new replies.

Advertisement