It is currently Fri Jun 23, 2017 10:37 am

All times are UTC - 5 hours




 Page 1 of 1 [ 7 posts ] 
Author Message
 Post subject: LNK2019 error
PostPosted: Sat Nov 30, 2013 8:10 pm 

Joined: Mon Nov 04, 2013 10:43 am
Posts: 9
I get this linker error and I have no idea what is causing it, I tried to google it but that didn't help:

GameOGL.obj : error LNK2019: unresolved external symbol __imp__timeGetTime@0 referenced in function "public: __thiscall GameOGL::GameOGL(class ErrorHandler *)" (??0GameOGL@@QAE@PAVErrorHandler@@@Z)
_Debug\Game Engine.exe : fatal error LNK1120: 1 unresolved externals

I am using VS2010 Professional Edition


Offline
 Profile  
 
 Post subject: Re: LNK2019 error
PostPosted: Sat Nov 30, 2013 8:43 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
timeGetTime is a function that is in an external library. You need to include the library where this function is found, into your project setting to fix this error. Google msdn timeGetTime to find the docs on this function. It will tell you there which library you need to link


Offline
 Profile  
 
 Post subject: Re: LNK2019 error
PostPosted: Sun Dec 01, 2013 12:55 am 

Joined: Mon Nov 04, 2013 10:43 am
Posts: 9
Thank you Marek,

I did as you said and included "Mmsystem.h" in GameOGL.cpp and I ended up adding:
#pragma comment (lib, "opengl32")
#pragma comment (lib, "glu32" )
#pragma comment (lib, "winmm" )
to my main.cpp
but now I get this error wich I believe is a seg fault but I don't know what could be causing this, here's the error msg:

Unhandled exception at 0x76ddaebf in Game Engine.exe: 0xC0000005: Access violation reading location 0xcccccccc.

since I'm using Visual Studio 2010 and I found it to be very substandard when it comes to pointing out exactly where the error occurs (even gdb does a better job) so I cannot really rely on where it is pointing which is the following line of code:

----> if (!RegisterClassEx(&m_WindowClassEx)) {
m_hInst = NULL;
m_pErrorHandler->SetError(EC_Windows, _T("Cannot register %s with Windows."), m_pszClassName);
return false;
}

if you see an obvious mistake that I am making could you please let me know how to resolve this issue?


Offline
 Profile  
 
 Post subject: Re: LNK2019 error
PostPosted: Sun Dec 01, 2013 2:39 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
It now sounds like you are trying to dereference a pointer that has not been initialized. While running your program in debug mode, step through it line by line until you get to the point when it throws the error. On the line before this, look at your variables to see which one is invalid. This will tell you what went wrong earlier.

I suspect that there is a problem in your GameOGL::initialize function. Possibly something to do with m_hWnd or how your Window was created.


Offline
 Profile  
 
 Post subject: Re: LNK2019 error
PostPosted: Sun Dec 01, 2013 6:23 pm 

Joined: Mon Nov 04, 2013 10:43 am
Posts: 9
Ok, I stepped through the code with the debugger and it turns out that my pszTitle is not being set in WindowsParameters I tried the following:

WindowParameters(TCHAR* _szTitle, HINSTANCE _hInst) {
      TCHAR* pszTitle = NULL;
      pszTitle = _szTitle;


and in my main I have the following:

TCHAR *szGameName = _T("Name of Game");


and then

WindowParameters WndParam(szGameName, hInst);


but for some reason pszTitle is not being set.


Offline
 Profile  
 
 Post subject: Re: LNK2019 error
PostPosted: Sun Dec 01, 2013 7:06 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Yuri13 wrote:
WindowParameters(TCHAR* _szTitle, HINSTANCE _hInst) {
      TCHAR* pszTitle = NULL;
      pszTitle = _szTitle;



why do you have pszTitle declared inside the constructor and set to NULL? You are passing in a value and setting it to this local variable, but as soon as the constructor is done, this variable is destroyed so your member variable inside WindowParameters is never set!

get rid of that first line.


Offline
 Profile  
 
 Post subject: Re: LNK2019 error
PostPosted: Sun Dec 01, 2013 11:25 pm 

Joined: Mon Nov 04, 2013 10:43 am
Posts: 9
Thank you Marek,

I appreciate your help, now everything works.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron