Cookie
Cookie

Reputation: 12652

C++ Link Error Missing GetTickCount And How To Debug

I have been refactoring some header includes, and all of sudden I am left with this (changed some namespaces and class names) link error:

Error 1 error LNK2001: unresolved external symbol "public: class ABC::DEF::JKL __thiscall ABC::GHI::GetTickCount(void)const " (?GetTickCount@GHI@ABC@@QBE?AVJKL@DEF@2@XZ) Server.obj

The thing is, there is not a single reference to GetTickCount in my code. I did a few clean rebuilds, to no avail.

What would be the next step to debug this? Is there any chance of finding out the offending line? From above message it looks as if the offending item is in the Server compilation unit, is it possible to narrow it down further? Why would I even get an unresolved external symbol that I never referenced?

Thanks

Upvotes: 2

Views: 1694

Answers (3)

Rian Sanderson
Rian Sanderson

Reputation: 6702

I'm assuming you're building on Windows, as GetTickCount() is a function provided from Kernel32 library.

You need to add Kernel32.lib into your linker library line. I usually do this from QMake with the line:

LIBS *= Kernel32.lib

Upvotes: 0

ks1322
ks1322

Reputation: 35708

Looks like this is release build of your code. Rebuild it in debug mode and linker should tell you exact line number of unresolved external in Server.obj.

Upvotes: 0

Cookie
Cookie

Reputation: 12652

Nevermind, winbase.h is so nice as to

#define GetCurrentTime() GetTickCount()

Upvotes: 5

Related Questions