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 f开发者_如何学编程urther? Why would I even get an unresolved external symbol that I never referenced?
Thanks
Nevermind, winbase.h is so nice as to
#define GetCurrentTime() GetTickCount()
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
.
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
精彩评论