Skip to main content
GameDev.net gamedev.net
🔒 Locked

DevC++ with SDL_image problams

Started by thedevil Apr 13, 2005 at 10:35 AM 17 replies 8.5k views
Original Post
thedevil
thedevil
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.
Drew_Benton
Drew_Benton
In your code I saw that you had this line:
#include /* 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
#include
That is my first suggestion/question [smile] Oh and you should wait at least 6 hours before a bump [wink], just a pointer.
thedevil
thedevil
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 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
Drew_Benton
Drew_Benton
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
thedevil
thedevil
okay, so i added the -lSDL_Image into the linker and it gives me the following error:

Drew_Benton
Drew_Benton
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?
thedevil
thedevil
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 ?
Drew_Benton
Drew_Benton
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].
thedevil
thedevil
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.
Drew_Benton
Drew_Benton
Quote:
Original post by thedevil
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 3 posts ago.


Oh let's check your versions of libraries -
SDL 1.2.8SDL Image 1.2.4ZLib 1.2.2LibTiff 3.4beta037Lib PNG 1.2.8Lib JPEG 6b-3

I have all of those and your program works on my computer.
thedevil
thedevil
everything is like you said except for libtiff which is in version 3.6.1-2 on my system. should i try version 3.4beta037 ?
Drew_Benton
Drew_Benton
Yes, definitly try that. Here's my project with .DLLs. See if you can get that to run. If so you might need to just re-download and install all of the libraries from the Dev-Paks site. I jsut got all the ones here for SDL_Image dependecies. After that make sure you copy all those .dlls into the working directory to make sure it looks there first for the .dlls. You might have a random library .dll somewhere else in your system folder that could be causing problems.
thedevil
thedevil
nope, i still get the same error, it happns during the run.
Drew_Benton
Drew_Benton
Try out my last post, I edited it. If that doesn't work...hmmm You might just need to uninstall Dev-CPP and delete all the stuff in the folders and do a reinstall, then redownload sdl 1.2.8 + all that other stuff.
thedevil
thedevil
okay, i copied all the dll's from your project (damn that a lot of dll's), and it worked, compiles and runs.
but now i have a new problam, when i run it the screen restarts turns black and the instead of showing the images it restarts again and goes to the desktop.
and by the when i run the .exe you put in your project i see the images and it works okay.
Drew_Benton
Drew_Benton
Quote:
Original post by thedevil
okay, i copied all the dll's from your project (damn that a lot of dll's), and it worked, compiles and runs.
but now i have a new problam, when i run it the screen restarts turns black and the instead of showing the images it restarts again and goes to the desktop.
and by the when i run the .exe you put in your project i see the images and it works okay.


That means you did not make an "images/" folder that has all your images in it for your chess. I changed them all to "1.png" since I don't have your gfx. That's all you need to do [smile].

Your section looks like:
background = IMG_Load("images/chessboard_classic.jpg");    blue_squre = IMG_Load("images/blue_squre.png");    soldier_white = IMG_Load("images/soldier_white.png");    soldier_black = IMG_Load("images/soldier_black.png");    fort_white = IMG_Load("images/fort_white.png");    fort_black = IMG_Load("images/fort_black.png");    horse_white = IMG_Load("images/horse_white.png");    horse_black = IMG_Load("images/horse_black.png");    prince_white = IMG_Load("images/prince_white.png");    prince_black = IMG_Load("images/prince_black.png");    queen_white = IMG_Load("images/queen_white.png");    queen_black = IMG_Load("images/queen_black.png");    king_white = IMG_Load("images/king_white.png");    king_black = IMG_Load("images/king_black.png");


Mine looks like:
 background = IMG_Load("1.png");    blue_squre = IMG_Load("1.png");    soldier_white = IMG_Load("1.png");    soldier_black = IMG_Load("1.png");    fort_white = IMG_Load("1.png");    fort_black = IMG_Load("1.png");    horse_white = IMG_Load("1.png");    horse_black = IMG_Load("1.png");    prince_white = IMG_Load("1.png");    prince_black = IMG_Load("1.png");    queen_white = IMG_Load("1.png");    queen_black = IMG_Load("1.png");    king_white = IMG_Load("1.png");    king_black = IMG_Load("1.png");
thedevil
thedevil
dear god im an ediot, your right and would just like to say to you thankyou, by all the beggining game developers out there thankyou, this has been a real hard nu to crack , the programming is easy (wel not all that much) but i have always had a block when it came to the other stuff (compiling other libraries, and debugging) but with this community every thing is possible !
Drew_Benton
Drew_Benton
Not a problem [smile] That's a lot of work you've already done with that program [wink] Have fun!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.