Sign in to follow this  
Lordimm

Linker Problem

Recommended Posts

Lordimm    122
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
emiel1    166
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this