# SDL_GetTicks() in SDL

## Recommended Posts

Hey hello, I have a small problem. In the past SDL_GetTicks() didn't gaved my any problems. But after updating SDl to the newest version I cannot use it anymore! If I just use simple things like this: counter = SDL_GetTicks() + 1000; if(counter < SDL_GetTicks() ) { blablah } This worked in the past but after updating it gives me some strange linkng errors. Due to this I cannot compile my tetris game anymore. Anyone else having this problems and anyone knows how to fix this? edit: those errors are: "Undifined reference to timeBeginPeriod@4", "Undifined reference to timeGetTime@0", "Undifined reference to GUID_Key" etc. (a huge list of those comparible things). The files that cuase these errors are SDL_systimer.c, SDL_dx5video.c, SDL_mmjoystick.c, SDL_dx5events.c, SDL_dx5yuv.c, SDL_dibaudio.c and SDL_syscdrom.c

##### Share on other sites
Koshmaar    989
What IDE and compiler are you using?

If it's DevCpp/(GCC/MinGW), then for linker you should pass this: -lmingw32 -lSDL -lSDLmain.

If it's Visual, then make sure you are compiling with Multithreaded DLL enabled, and don't forget to link to SDL.lib and SDLmain.lib.

##### Share on other sites
I'm using codeblocks.
And I already linked those libmingw32.a and all other library files I use.

Anyone knows what to do?

##### Share on other sites
Koshmaar    989
Quote:

Yes, learn to use Google [rolleyes]

##### Share on other sites
IronGryphon    324
The compiler knows what directory the SDL SDK is in right?

Just to test if SDL is linked you can try a bare bones code segment. Not sure what you've tried. Just trying to help.

#include <iostream>#include <stdlib.h>#include "SDL.h"using namespace std;int main(int argc, char *argv[]){ cout <<"Initializing SDL." << endl;  /* Initializes Audio and the CDROM, add SDL_INIT_VIDEO for Video */  if(SDL_Init(SDL_INIT_AUDIO | SDL_INIT_CDROM)< 0) {    cout <<"Could not initialize SDL:" << SDL_GetError() << endl;       SDL_Quit();  } else {    cout << "Audio & CDROM initialized correctly" << endl;;    /* Trying to read number of CD devices on system */	cout << "Drives available :" << SDL_CDNumDrives() << endl;    for(int i=0; i < SDL_CDNumDrives(); ++i) {      cout << "Drive " << i << "\"" << SDL_CDName(i) << "\"";    }  }  SDL_Quit();}

##### Share on other sites
Btw I triple checked that wifi page and did everything they say but still doesn't work.

I made SDL folders inside my include and lib dir were I put all header and lib files but still same error.

##### Share on other sites
lonesock    807
I think that the library necessary would be "libwinmm.a". If you are already linking that, I've found that the MinGW compiler can be very picky about the order of the libraries included, so you may want to try moving the "-lwinmm" flag farther back (or forward) in order.

BTW, does this mean that you are having trouble compiling SDL (static or dynamic), or that you are using the SDL source directly in your project?

##### Share on other sites
hm.. I'm wasn't linking that libwinmm file. After doing so I solved most of that undefined reference to timeBeginTimer stuff but I still have alot of those left lke tat GUID_Key and IID_DirectDrawSurface3 undefined references and some others.

Do I need to link to more library files??

Btw I'm just linking SDL dynamicly if I'm right. I'm not uing the surce or something, just using the SDL.dll file (I need that one to execute the programs).

##### Share on other sites
lonesock    807
Yep, you will need to link more library files. Here's my cheater technique:

- find an "undefined reference" error, e.g. "timeGetTime"
- go to the "lib" directory (under codeblocks)
- search for all *.a files containing the text "timeGetTime"
- link that library file and see if the errors go away
- repeat as necessary