Sign in to follow this  
philipptr

sdl and dev-c++ problems

Recommended Posts

philipptr    260
disclaimer: i have googled on the whole net aswell as on the formus and found no solution to the following problem :D im coding a game in c++ with sdl and dev-c++ and everything worked fine until i reinstalled dev-c++ to move it onto my second partition. now i get a lot of linker errors even though i used the dev-c++ sdl version. here's some information about the problem: i use the following parameters for the project: c++ compiler: -lmingw32 -lSDLmain -lSDL linker: E:/Dev-Cpp/lib/libSDL.a E:/Dev-Cpp/lib/libSDLmain.a the beginning of my code looks like this:
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <SDL/SDL.h>
#include <SDL/SDL_main.h> //somebody on the net said id have to include it, but i see no difference
#include <SDL/SDL_thread.h>

#ifdef _WIN32
#undef main
#endif

errors: [Linker error] undefined reference to `timeBeginPeriod@4' [Linker error] undefined reference to `timeGetTime@0' [Linker error] undefined reference to `timeBeginPeriod@4' [Linker error] undefined reference to `GetSystemPaletteEntries@16' [Linker error] undefined reference to `CreatePalette@4' and so on, these are only a few. so if i dont use the linker parameters the errors look like this: [Linker error] undefined reference to `SDL_Init' [Linker error] undefined reference to `SDL_GetError' [Linker error] undefined reference to `SDL_Delay' [Linker error] undefined reference to `SDL_Quit' [Linker error] undefined reference to `SDL_SetVideoMode' and so on. i hope somebody knows how to solve this problem

Share this post


Link to post
Share on other sites
Fruny    1658
The first set are Win32 functions. Are you linking to the appropriate windows libraries? Your linker flags don't, and I don't know if the SDL headers contain linker #pragmas.

Share this post


Link to post
Share on other sites
philipptr    260
well that wasnt the problem (the 3 lines were copied form somewhere becuase it didnt work anymore after i put the code in a terminal project, i actually dont know exactly what it does ;) ), but i found the solution now: i had to put the "-lmingw32 -lSDLmain -lSDL" in the linker parameters (saw it in a template dev-c++ sdl project)

though i have still 2 questions: im thinking about putting the code into a real dev-c++ sdl project, so that the terminal window doesnt appear anymore, but then i couldnt use the cout for debug information anymore, any ideas how to solve that?
and the sdl projects include windows wouldnt that make it a bit more difficult for porting it to windows?

Share this post


Link to post
Share on other sites
Drew_Benton    1861
Quote:
Original post by philipptr
im thinking about putting the code into a real dev-c++ sdl project, so that the terminal window doesnt appear anymore, but then i couldnt use the cout for debug information anymore, any ideas how to solve that?


You will want to simply add in a console window to your program. That way you can easily use it and remove it when you need to.

Quote:
Original post by philipptr
well that wasnt the problem (the 3 lines were copied form somewhere becuase it didnt work anymore after i put the code in a terminal project, i actually dont know exactly what it does ;) ),


Well that was the problem as Frunny has said -

c++ compiler: <---- Eeek! (Compiler directives, not linker)
-lmingw32
-lSDLmain
-lSDL

linker: <---- linker directives
E:/Dev-Cpp/lib/libSDL.a
E:/Dev-Cpp/lib/libSDLmain.a

If you added the E:/Dev-Cpp/lib/mingw32.a file to the linker directives, then it would have worked fine. It was just you added everything but that, thus creating the windows specific errors. Well you still would have had to make SDLMain come before SDL, but that's ok, you know how to do it now [wink].

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this