PDA

View Full Version : Windows Hello World



anarchyhl
05-01-2002, 12:49 PM
Alright, I have the book OpenGL Game Programming, and in Chapter 2(Windows with OpenGL), there is a Hello World program for windows. Well, my compiler(MS-VC++) said cant execute cl.exe or something. On my other computer, it executes just fine if i use the dsw file, but when i try to compile the source on both computers it gives me that error. Here is the code:

#include <windows.h>

#define WIN32_LEAN_AND_MEAN

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
MessageBox(NULL, "\tHello, world!", "My First Windows Application", 0);
return 0;
}

Anybody here know why I may be having this problem?

Deiussum
05-02-2002, 04:21 AM
The DSW sets up a workspace which contains one or more project files (DSP). These project files contain things such as compiler flags, linker flags, libraries to link in, source files to use, etc. If you are trying to just compile a .cpp, you will also need to provide the right comiler flags, linker flags, etc.

If you were to provide an example error, it would be a whole lot easier to tell you what exactly you need. "Error executing cl.exe" usually only happens because the compiler failed, so if you could show the error that the compiler generated, it would be so much easier.

Edit: Looked through your code again quick, and while I didn't find anything in the code that would cause a failure, I did notice a couple of minor little symantical things.

You #define WIN32_LEAN_AND_MEAN after you #include <windows.h>. This won't have the effect you want. Windows.h will only include basic stuff when that is defined, but you aren't defining it until AFTER it's been included, so it's pretty much useless there. Put it before the #include.

This is just a readability thing, but it would be better to use MB_OK for your last parameter of MessageBox. I had to go look up what the value was of the valid constants for that to see what sort of MessageBox you were trying to create. Again, nothing the compiler would complain about, just something to make the code more friendly to other people reading it. http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by Deiussum (edited 05-02-2002).]

JnZ
05-02-2002, 05:15 AM
Aaah. The famous "Hello world" prog..Every coder has seen it.




#define WIN32_LEAN_AND_MEAN
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lCmdLine, int iCmdShow)
{
MessageBox(0, "Hello, world", "Hello, world caption", MB_OK);
return 0;
}





[This message has been edited by JnZ (edited 05-02-2002).]