• Advertisement

• ### Popular Now

• 11
• 9
• 10
• 9
• 10
• Advertisement
• Advertisement
• Advertisement

# WinSDK Madness...

This topic is 3732 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

Ok so I returned to programming today after a long time. So I start making a simple startup DirectX program from the book and SDK documentation. I haven't even gotten to that point yet to even add in any of that code. I'm stuck trying to make a window, but it's not quite working. Here's how it's gone. I programmed all my code as such:
#include <Windows.h>

//Function prototypes

//handles the messages passed to it from message loop
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
{
//Define a window class
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L, hInstance,
NULL, NULL, NULL, NULL, "ClayWinClass", NULL };

//Register the window class
RegisterClassEx(&wc);

//Create the window to show to user
HWND hWnd = CreateWindow("ClayWinClass", "Clay Engine Window", WS_OVERLAPPEDWINDOW,
0, 0, 450, 450, NULL, NULL, hInstance, NULL);

//declare a Windows Message type and clear it out
MSG msg;
ZeroMemory(&msg, sizeof(MSG));

while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
//game instructions here when not handling messages
}
}

//Unregister the class to clean it up in system
UnregisterClass("ClayWinClass", hInstance);
//return and end program
return 0;
}

//handles the messages sent by windows to window
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
break;
}

return 0;
}


But as soon as I tried to build it, it told me that it couldn't even find the windows.h file. I'm going 'wtf?!' by this point. I do some online searching for 'missing windows.h' and even found a gamedev forum solution, that VC++ 2005 Express doesn't have the file and I must download the Windows SDK. So I go download that. Then go into VC++ under the Project->Clay Properties (Clay is my project name) go to the C/C++ General tab, and even add Additional Include Directories as needed to point to the include directory in the SDK folder. I even do so for the lib directory under the Linker General tab. I can compile my project now, but I can't build it?? I close the whole thing down, and then run the "Integrate Windows SDK with Visual Studio 2005" program that came with the SDK under the start menu. I open up my project again, and try building again. Still only compile and no build. I try cleaning the build, rebuild, and etc. I even just copied all the files from the SDK directories to my compiler directories for the include and lib files. Still nothing. I'm really confused how it's compiling but not building?? Here are the messages I'm getting.
------ Build started: Project: Clay, Configuration: Release Win32 ------
Linking...
WinMain.obj : error LNK2019: unresolved external symbol __imp__PostQuitMessage@4 referenced in function "long __stdcall WinProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WinProc@@YGJPAUHWND__@@IIJ@Z)
WinMain.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcA@16 referenced in function "long __stdcall WinProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WinProc@@YGJPAUHWND__@@IIJ@Z)
WinMain.obj : error LNK2019: unresolved external symbol __imp__UnregisterClassA@8 referenced in function _WinMain@16
WinMain.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageA@4 referenced in function _WinMain@16
WinMain.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function _WinMain@16
WinMain.obj : error LNK2019: unresolved external symbol __imp__PeekMessageA@20 referenced in function _WinMain@16
WinMain.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function _WinMain@16
WinMain.obj : error LNK2019: unresolved external symbol __imp__RegisterClassExA@4 referenced in function _WinMain@16
C:\Documents and Settings\Nathan\Desktop\Nathan\Programming\Projects\Clay\Release\Clay.exe : fatal error LNK1120: 8 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Nathan\Desktop\Nathan\Programming\Projects\Clay\Release\BuildLog.htm"
Clay - 9 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Can someone please provide some insight as to what the hell I could possibly be doing wrong by this point? Completely lost at this point, and already getting to the "grrr f this point". Thanks in advance to anyone who can help. [Edited by - Xelen on February 1, 2008 6:50:12 PM]

#### Share this post

##### Share on other sites
Advertisement
Oh, and what are the [ tags ] again for adding code into a post? I tried [ code ], without the spaces of course, but I guess that wasn't it. Can't remember anymore. :( Thanks for that too :)

#### Share this post

##### Share on other sites
Read this. Apparently you don't need to do this with VC2008 though.

And the tags are [ source ] [ /source ].

#### Share this post

##### Share on other sites
Ok, thank you for the answer to both things. The whole thing still wasn't working for me, so I just decided to un-install the SDK and VC 2005, and install VC 2008. Of course that works and was a whole lot easier than everything I've tried by a longshot, makes me wish I had thought of it in the first place... :)

#### Share this post

##### Share on other sites
I have same problem before a long time ago. If I'm not mistaken it cause by VS project setting.

#### Share this post

##### Share on other sites

• Advertisement