PDA

View Full Version : Link error while trying to use timeGetTime



K A Z E
12-25-2005, 06:59 PM
I downloaded a demo from ultimategameprogramming.com that works based on time rather than frames. Well, it uses this fucntion: timeGetTime(). When I try to compile it, I get this error:

--------------------Configuration: TimeBasedCamera - Win32 Debug--------------------
Compiling...
CCamera.cpp
Linking...
CCamera.obj : error LNK2001: unresolved external symbol __imp__timeGetTime@0
Debug/TimeBasedCamera.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Creating browse info file...

TimeBasedCamera.exe - 2 error(s), 0 warning(s)

I right clicked the function and hit go to declaration. It's declared in MMSYSTEM.H which is included in windows.h. I checked the include section where my compiler is installed, but I can't find a MMSYSTEM.CPP, so I'm not sure it's ever initialized, which would cause a link error if it's not... But that would just be weird. Or do I need to link a library file or something? Unlike NeHe's demos, he doesn't include a project file. Just the cpps, which sux. And I don't think he mentions any library files in the cpp, although I admit I'm too lazy to look through the whole thing, I just searched for the words "link", "library", "libraries", and "lib". =)

Anyway, any help would be appreciated. And thanks in advance.

hazelwood
12-25-2005, 11:29 PM
link to winmm.lib

K A Z E
12-26-2005, 01:55 AM
Awesome. Thanks. =)

K A Z E
12-26-2005, 03:40 AM
Okay new problem. While the demo compiles, when I try to use timeGetTime in my program I get a COMPILE error. When I call it in this line:

DWORD iTime = timeGetTime();

It gives me this error:

--------------------Configuration: Textured Room - Win32 Debug--------------------
Compiling...
Textured Room.cpp
C:\Documents and Settings\Owner\Desktop\Icon Folder\OpenGL Programming Stuff\Textured Room\Textured Room.cpp(147) : error C2065: 'timeGetTime' : undeclared identifier
Error executing cl.exe.
Creating browse info file...

Textured Room.exe - 1 error(s), 0 warning(s)

So I right click and hit go to definition and it pops up a box that says "Resolve Ambiguity" and my options are:

timeGetTime (variable)
timeGetTime (function)

Click the function and it takes me to where its declared in MMSYSTEM.H. If I click variable it highlights my call to timeGetTime... For some reason the stupid thing seems to think that when I say DWORD iTime = timeGetTime(); that I'm trying to set iTime equal to a variable named timeGetTime, EVEN THOUGH I have the parenthesis which should clearly indicate to the stupid piece of junk that it's the FUNCTION I'm refering to... Even if I had a variable named timeGetTime, it would then complain about the parenthesis indicating that I was calling a function. Can anyone tell me what's wrong with this stupid thing and how to fix it? Or is my compiler just retarded or something? Or just trying to piss me off...

Any help would be appreciated and thanks in advance.