• Advertisement
Sign in to follow this  

missing windows.h? SOLVED

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

I just installed VC++2005 Express. I started writing some code, and went to "#include <windows.h>" 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]

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!!!

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement