Public Group

# sdl and dev-c++ problems

This topic is 4804 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

#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 on other sites
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 on other sites
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 on other sites
Quote:
 Original post by philipptrim 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 philipptrwell 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

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 on other sites
ooops, i thought fruny ment somehting else, well atleast it works now [wink]

• 23
• 10
• 19
• 15
• 14