Hey, I'm new here so if this isn't in the right place sorry. I put it in the DirectX section because I'm following this book:
http://www.amazon.com/Beginning-DirectX-11-Game-Programming/dp/1435458958
I am on the second chapter and well the first thing it does is teaches you how to display a window using WinApi. I have some knowledge but I'm not very familiar with this and don't know how to fix this error.
Here is the code:
#include<Windows.h>
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow )
{
UNREFERENCED_PARAMETER( prevInstance );
UNREFERENCED_PARAMETER( cmdLine );
WNDCLASSEX wndClass = {0};
wndClass.cbSize = sizeof( WNDCLASSEX ) ;
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.hInstance = hInstance;
wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndClass.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 );
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = "DX11BookWindowClass";
if(!RegisterClassEx(&wndClass))
return-1;
RECT rc = {0, 0, 640, 480};
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
HWND hwnd = CreateWindowA("DX11BookWindowClass", "Blank Win32 Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
if(!hwnd)
return -1;
ShowWindow(hwnd, cmdShow);
MSG msg = {0};
while(msg.message != WM_QUIT)
{
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
//Update
//Draw
}
}
return static_cast<int>(msg.wParam);
}
And the error:
1>------ Build started: Project: BlankWindow, Configuration: Debug Win32 ------
1> main.cpp
1> LINK : c:\users\trevor peyton\documents\visual studio 2010\Projects\DXBook\BlankWindow\Debug\BlankWindow.exe not found or not built by the last incremental link; performing full link
1>main.obj : error LNK2019: unresolved external symbol "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z) referenced in function _wWinMain@16
1>c:\users\trevor peyton\documents\visual studio 2010\Projects\DXBook\BlankWindow\Debug\BlankWindow.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I got two things from this.
1. It obviously has something to do with:
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );
and
wndClass.lpfnWndProc = WndProc;
2. (I think) that it is a linking error... and I'm not really sure what it's linking. new to C++ (more of a C# guy).
Any help is much appreciated, thanks.