Skip to main content
GameDev.net gamedev.net
🔒 Locked

missing windows.h? SOLVED

Started by trick Mar 21, 2007 at 5:05 PM 14 replies 48.9k views
Original Post
trick
trick
I just installed VC++2005 Express. I started writing some code, and went to "#include " to access the RECT structure. When I try to compile I get an error that it cannot find windows.h. Does anyone know what's going on, or has had the same problem? [Edited by - trick on March 22, 2007 4:28:29 AM]
andbna
andbna
Unless im mistaken, the express edition comes only with the C++ standard library by default, and you must download the Microsoft Platform SDK and set your compiler up to use it: http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en

-Andrew
trick
trick
Thanks much!

Got it downloaded, and installed. I started building up a test program to make sure there were no errors, but my compiler is finding errors inside "winnt.h". Errors below, anyone know what may be going on? Also posted below the errors, is code from winnt.h where the errors occur.

Quote:

C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(5940) : error C2146: syntax error : missing ';' before identifier 'Buffer'
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

typedef void *PVOID;typedef void * POINTER_64 PVOID64; //line#222

typedef union _FILE_SEGMENT_ELEMENT {    PVOID64 Buffer; //line#5940    ULONGLONG Alignment;}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
Crypter
Crypter
Can you please post the code for your test program?
trick
trick
Sure.

//BlockBuster.cpp#include <windows.h>#include <d3d9.h>HINSTANCE hInst;HWND wndHandle;LPDIRECT3D9 pD3D;LPDIRECT3DDEVICE9 pd3dDevice;bool initWindow(HINSTANCE hInstance);LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);bool initDirect3D();void update(float x){}void render(){	if(NULL == pd3dDevice)		return;	pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);	pd3dDevice->BeginScene();	pd3dDevice->EndScene();	pd3dDevice->Present(NULL, NULL, NULL, NULL);}void cleanup(){	if(pd3dDevice != NULL)		pd3dDevice->Release();		if(pD3D != NULL)		pD3D->Release();}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){	float last_time = 0.0f;	if(!initWindow(hInstance))		return false;	if(!initDirect3D())		return false;	MSG msg;	ZeroMemory(&msg, sizeof(msg));	float time_total = 0.0f;	while(msg.message != WM_QUIT){		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){			TranslateMessage(&msg);			DispatchMessage(&msg);		}else{		}	}	cleanup();	return 0;}bool initWindow(HINSTANCE hInstance){	WNDCLASSEX wc;	wc.cbSize = sizeof(WNDCLASSEX);	wc.style = CS_HREDRAW | CS_VREDRAW;	wc.lpfnWndProc = (WNDPROC)WndProc;	wc.cbClsExtra = 0;	wc.cbWndExtra = 0;	wc.hInstance = hInstance;	wc.hIcon = 0;	wc.hCursor = LoadCursor(NULL, IDC_ARROW);	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);	wc.lpszMenuName = NULL;	wc.lpszClassName = "Block Buster";	wc.hIconSm = 0;	RegisterClassEx(&wc);	wndHandle = CreateWindow("Block Buster", "Block Buster", WS_OVERLAPPEDWINDOW, 100, 100, 800, 600, NULL, NULL, hInstance, NULL);//replace 100 with CW_USEDEFAULT	if(!wndHandle)		return false;	ShowWindow(wndHandle, SW_SHOW);	UpdateWindow(wndHandle);	return true;}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){	switch(message){	case WM_DESTROY:		PostQuitMessage(0);		break;	}	return DefWindowProc(hWnd, message, wParam, lParam);}bool initDirect3D(){	pD3D = NULL;	pd3dDevice = NULL;	if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))){		return false;	}	D3DPRESENT_PARAMETERS d3dpp;	ZeroMemory(&d3dpp, sizeof(d3dpp));	d3dpp.Windowed = TRUE;	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;	d3dpp.BackBufferCount = 1;	d3dpp.BackBufferHeight = 600;	d3dpp.BackBufferWidth = 800;	d3dpp.hDeviceWindow = wndHandle;	if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wndHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice))){		return false;	}	return true;}

This is entire source code of test program. Very basic, just supposed to initialize directx and a window to display.
Crypter
Crypter
Quote:

Microsoft Platform SDK for Windows Server 2003 R2

This is not the Win32 Platform SDK..

You need This one
(Same one posted in Simian Man's post)

Insure to follow all of the instructions (You may need to set up library
and include paths). Also, you may need to edit certain files (as the
instructions direct)

After setting this up, try to build a minimal Win32 program (No Direct3d),
and tell us what happens..
nemesisgeek
nemesisgeek
Did you add the Platform SDK include directory to your settings?

I can't give you directions myself because I use VC++ 6, but here's some info from Microsoft's website:

Step 1-2: (install VC++ Express and download Platform SDK)

Step 3: Update the Visual C++ directories in the Projects and Solutions section in the Options dialog box.
Add the paths to the appropriate subsection:

Executable files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin
Include files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include
Library files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib
Note: Alternatively, you can update the Visual C++ Directories by modifying the VCProjectEngine.dll.express.config file located in the \vc\vcpackages subdirectory of the Visual C++ Express install location. Please make sure that you also delete the file "vccomponents.dat" located in the "%USERPROFILE%\Local Settings\Application Data\Microsoft\VCExpress\8.0" if it exists before restarting Visual C++ Express Edition.



Step 4: Update the corewin_express.vsprops file.
One more step is needed to make the Win32 template work in Visual C++ Express. You need to edit the corewin_express.vsprops file (found in C:\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults) and

Change the string that reads:

AdditionalDependencies="kernel32.lib"

to

AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"

hackerkey://v4sw7+8CHS$hw6+8ln6pr8O$ck4ma4+9u5Lw7VX$m0l5Ri8ONotepad++/e3+8t3b8AORTen7+9a17s0r4g8OP
trick
trick
the link on that page takes me to a page to download/install...

Microsoft ® Windows Server® 2003 R2 Platform SDK Web Install

Sorry, I'm just not seeing it. This looks like what I did before...
Crypter
Crypter
This link?

"Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK"
trick
trick
Yes.
Quote:

Step 2: Install the Microsoft Platform SDK.
Install the Platform SDK over the Web from the Download Center. Follow the instructions and install the SDK for the x86 platform.



Step 3: Update the Visual C++ directories in the Projects and Solutions section in the Options dialog box.
Add the paths to the appropriate subsection:

Executable files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin
Include files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include
Library files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib


After clicking the link to install the SDK, the page has a big header saying...
Quote:

Microsoft ® Windows Server® 2003 R2 Platform SDK Web Install
Crypter
Crypter
I see.. Mabey Microsoft isnt distributing the Win32 API anymore..?

With some searching, I think This should work

According to the website:
Quote:

This SDK is designed for use with Windows Vista (which includes Framework 3.0). The Windows SDK for Vista also supports creating applications for Windows XP, Windows Server® 2003 SP1, and Windows Server 2003 R2.
Hollower
Hollower
The Windows Server 2003 version is the correct PSDK for the Express Edition - always has been. It was the same back when I installed it over a year ago. The link Sneftel gave indicates the real problem. In case you missed it in that thread the problem is that both the Platform SDK and the DirectX 9 SDK come with a BaseTsd.h file, and the DirectX 9 version isn't compatable with that winnt.h file where the error occured. Obviously, the DX9 include folder comes first in the path so that is the one it tries to use. You can probably fix the problem by simply renaming the DX9 BaseTsd.h file to something else like BaseTsd_.h. But to be safe don't delete or overwrite it. I'm not sure if reordering the include paths will help or cause more problems.
trick
trick
re-ordering them did help. I put the windows SDK folders at the start of the list. Of course, now I'm getting a linker error but...
(strange thing is, I know what the linker error means, but don't understand why I'm getting it..lol).

Quote:

BlockBuster.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function "bool __cdecl initDirect3D(void)" (?initDirect3D@@YA_NXZ)



EDIT: Problem solved. Thanks for help!!!
nemostyle
nemostyle
Quote:
Original post by nemesisgeek

Step 4: Update the corewin_express.vsprops file.
One more step is needed to make the Win32 template work in Visual C++ Express. You need to edit the corewin_express.vsprops file (found in C:\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults) and

Change the string that reads:

AdditionalDependencies="kernel32.lib"

to

AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"


Thank you very much!
I installed Vista and downloaded the SDKs, and my projects wouldn't build :(
I was getting unresolved externals for all my basic windows calls.
I checked my directory settings and they all looked fine.

The corewin_express.vsprops edit you had posted worked like a charm! Now I can resume as if the Vista transition never was ;)

Thanks again!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.