• Advertisement
Sign in to follow this  

Linker Problem

This topic is 3359 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm getting closer to getting this window to work, just this problem now with this code. #include "Library.h" LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wcex = { sizeof(WNDCLASSEX), CS_CLASSDC, WindowProc, 0L, 0L, hInstance, NULL, NULL, NULL, NULL, "GameClass", NULL }; //Register the class and exit on error if(!RegisterClassEx(&wcex)) return FALSE; HWND hWnd; // Our window's handle hWnd = CreateWindow("GameClass", "My Game Class", WS_OVERLAPPEDWINDOW, 320, 240, 0, 0, NULL, NULL, hInstance, NULL); if(hWnd == NULL) return FALSE; // Show the window ShowWindow(hWnd, SW_SHOWNORMAL); UpdateWindow(hWnd); // Enter the message pump MSG msg; // Clear out the message structure while(msg.message != WM_QUIT) { // Peek into the queue and see if there's a message waiting if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { //No messages waiting. Go ahead and do time-crucial //Stuff here, such as rendering the game's graphics } } //Unregister class UnregisterClass("GameClass", hInstance); //Do other application stuff here //Exit application return 0; } c:\documents and settings\owner\my documents\visual studio 2008\projects\rpg3\rpg3\winmain.cpp(35) : warning C4700: uninitialized local variable 'msg' used Linking... WinMain.obj : error LNK2019: unresolved external symbol "long __stdcall WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProc@@YGJPAUHWND__@@IIJ@Z) referenced in function _WinMain@16 C:\Documents and Settings\Owner\My Documents\Visual Studio 2008\Projects\RPG3\Debug\RPG3.exe : fatal error LNK1120: 1 unresolved externals

Share this post


Link to post
Share on other sites
Advertisement
You have declaired WindowProc, but you haven't defined it:


LRESULT CALLBACK WindowProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch (message)
{
case WM_DESTROY: // Window is Destroyed
{
PostQuitMessage(0);
return 0;
} break;
case WM_OTHER_MESSAGE: // Keep listing the messages here
{
// Respond to every message here
} break;
default:
{
return DefWindowProc (hWnd, message, wParam, lParam);
}
}
}





Also, you must clear out the msg, not just say it in a comment.

[Edited by - emiel1 on December 14, 2008 4:30:42 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement