Tim Lewis
Tim Lewis

Reputation: 1

Visual Studio not creating a .exe

I've actually just found another thread Identical to my own which has been solved, sorry for duplicates.

Link to solved thread: DirectX unresolved external error

So I've started to try some DirectX 11 with the help of a Begginer's book, although at my first debug I'm having errors :S

I've even copied the code word for word from the book just to make sure I'm not making any silly syntax erros, although I am still getting the error:

Unable to start program 'C:.....\DXBlankWindow.exe'. The system cannot find the file specified.

Error 1:

error LNK2019: unresolved external symbol "long stdcall WndProc(struct HWND *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z) referenced in function _wWinMain@16 C:\Users\Tim\Documents\Visual Studio 2010\Projects\DirectXTuts\DXBlankWindow\DXBlankWindow\main.obj

Error 2:

error LNK1120: 1 unresolved externals C:\Users\Tim\Documents\Visual Studio 2010\Projects\DirectXTuts\DXBlankWindow\Debug\DXBlankWindow.exe 1

And after checking the projects debug folder there isn't a .exe file created.

I've also run a simple program to check if the project will run and it does this fine and creates the .exe file, and I've changed the runtime library to 'Multi Threaded Debug (/MTd).

I'm probably doing something very basic and very simple wrong, but I can't for the life of me work out what. Any help would be really really appreciated. I guess theres nothing more to say other than here's the code:

#include<Windows.h>

// Define WndProc
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );

// Program Entry Point
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow )
{

// Define unused parameters
UNREFERENCED_PARAMETER( prevInstance );
UNREFERENCED_PARAMETER( cmdLine );

// Define Window variables
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";

// Check if wndClass is being registered, if not error.
if( !RegisterClassEx( &wndClass ) )
return -1;

// Create a RECT to hold the screen positions
RECT rc = { 0, 0, 640, 480 };
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );


// Create The Window through ANSI
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 );


// Demo Initialize

MSG msg = { 0 };

while( msg.message != WM_QUIT )
{
if( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}

// Update
// Draw
}

// Demo Shutdown

return static_cast<int>( msg.wParam );
}

Thanks again.

Upvotes: 0

Views: 680

Answers (1)

user743382
user743382

Reputation:

// Define WndProc
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );

No, that doesn't define WndProc, that declares WndProc. In other words, that tells the rest of your code that there is a WndProc somewhere, so that wndClass.lpfnWndProc = WndProc; doesn't result in a compilation error. It is up to you to make sure you really do have a WndProc. That is what the linker error message is trying to tell you.

Or, put it simpler, if you tell the system to use a WndProc that isn't there, the system cannot really do anything but tell you.

Edit: looking at the duplicate, you seem to be using a book with incomplete samples. I am not familiar with the book, but if that is giving you trouble, you might want to look for another one.

Upvotes: 2

Related Questions