Samapico Posted April 29, 2007 Report Posted April 29, 2007 I just started playing around with Merv stuff... but now I'm getting an error from the linker when it's building the exe: Error 1 error LNK2019: unresolved external symbol "private: class timerms __thiscall botInfo::testtimer(void)" (?testtimer@botInfo@@AAE?AVtimerms@@XZ) referenced in function "public: void __thiscall botInfo::gotCommand(struct Player *,struct Command *)" (?gotCommand@botInfo@@QAEXPAUPlayer@@PAUCommand@@@Z) command.obj The bug comes from the line:int timervalue = testtimer().ReadTimer();ReadTimer() is a int function of the class 'timerms' I get linker errors anytime I call a non-void method within that class... wtf... What am i doing wrong? Here's the relevant code... If you notice anything weird or stuff I shouldn't be doing, please tell me, even if it's not related to the problem... It's the first time I do C++ spawn.h[...] #include "timerms.h" [...] class botInfo { // Put bot data here timerms testtimer(); [...] commands.cpp#include "spawn.h" [...] void botInfo::gotHelp(Player *p, Command *c) { [...] int timervalue = testtimer().ReadTimer(); //Could be any other non-void call, it does the same error [...] timerms.h#include "spawn.h" #define NOT_INITIALIZED -1 class timerms { int starttime; int pausetime; public: timerms() { ResetTimer(); } bool isrunning; bool ispaused() { return (!isrunning && pausetime != NOT_INITIALIZED);} void StartTimer(int starttime); void StartTimer(); void PauseTimer(int pausetime); void PauseTimer(); void ResumeTimer(int resumetime); void ResumeTimer(); void ResetTimer(); int ReadTimer(); ~timerms() { } }; timerms.cpp#include "spawn.h" [...] int timerms::ReadTimer() { return 0; //No matter what code in here, gives the same error } I searched on Google and the only thing I found was about some libraries and stuff... but I'm not using any API or external dll or whatever... I'm using Visual Studio 2005 professionnal
»Maverick Posted April 29, 2007 Report Posted April 29, 2007 Got to move this to the Game Development department
»D1st0rt Posted April 29, 2007 Report Posted April 29, 2007 change timerms testtimer();andint timervalue = testtimer().ReadTimer(); to timerms testtimer;andint timervalue = testtimer.ReadTimer();
Samapico Posted April 29, 2007 Author Report Posted April 29, 2007 yeah just fixed it... heh thanks I thought it was weird to have testtimer().Method, but it wasn't letting me do it otherwise... Needed to get rid of the ()'s in the declaration too... eh.. Thought it was needed for constructor stuff, but since it's a class member, it can't be initialized anyway... mhm
Recommended Posts