Results 1 to 3 of 3

Thread: Windows Hello World

  1. #1

    Windows Hello World

    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?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Fargo, ND

    Re: Windows Hello World

    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.

    [This message has been edited by Deiussum (edited 05-02-2002).]
    Software Engineer and OpenGL enthusiast

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2001
    Espoo, Finland

    Re: Windows Hello World

    Aaah. The famous "Hello world" prog..Every coder has seen it.

    Code :
    #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).]
    Follow the white rabbit...

Similar Threads

  1. COVERSION: world coord -> screen coord -> world coord
    By Albert85 in forum OpenGL: GLSL
    Replies: 8
    Last Post: 01-12-2015, 06:41 PM
  2. Putting a windows form in a Opengl 3d world?
    By minidoggy in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-21-2011, 03:47 PM
  3. Windows OpenGL 3 Hello World Demo Released
    By dpoon in forum OpenGL: Windows
    Replies: 2
    Last Post: 08-11-2009, 01:54 AM
  4. Continuous World / World Wrapping
    By MicahBrening in forum OpenGL: Basic Coding
    Replies: 13
    Last Post: 02-24-2007, 06:46 PM
  5. Replies: 4
    Last Post: 01-30-2006, 03:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean