Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Why my code can not be compiled :(

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2005
    Posts
    1

    Why my code can not be compiled :(

    my code is at below:

    /********************************************/
    #include <GL/glut.h>
    #include <GL/glu.h>
    #include <GL/gl.h>
    #include <windows.h>

    main()
    {
    InitializeAWindowPlease();

    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    glBegin(GL_POLYGON);
    glVertex3f(0.25, 0.25, 0.0);
    glVertex3f(0.75, 0.25, 0.0);
    glVertex3f(0.75, 0.75, 0.0);
    glVertex3f(0.25, 0.75, 0.0);
    glEnd();
    glFlush();
    UpdateTheWindowAndCheckForEvents();
    }
    /***********************************************/

    When I build that.. there would be 4 errors:

    1.
    test_one.obj : error LNK2001: unresolved external symbol _UpdateTheWindowAndCheckForEvents

    2.
    test_one.obj : error LNK2001: unresolved external symbol _InitializeAWindowPlease

    3.
    LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

    4.
    Debug/test_one.exe : fatal error LNK1120: 3 unresolved externals

    please help me...why such errors are there.....

    Thanks!

  2. #2
    Intern Contributor
    Join Date
    Jan 2005
    Location
    Karachi, Pakistan
    Posts
    86

    Re: Why my code can not be compiled :(

    Originally posted by Marco2005:
    my code is at below:

    /********************************************/
    #include <GL/glut.h>
    #include <GL/glu.h>
    #include <GL/gl.h>
    #include <windows.h>

    main()
    {
    InitializeAWindowPlease();

    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    glBegin(GL_POLYGON);
    glVertex3f(0.25, 0.25, 0.0);
    glVertex3f(0.75, 0.25, 0.0);
    glVertex3f(0.75, 0.75, 0.0);
    glVertex3f(0.25, 0.75, 0.0);
    glEnd();
    glFlush();
    UpdateTheWindowAndCheckForEvents();
    }
    /***********************************************/

    When I build that.. there would be 4 errors:

    1.
    test_one.obj : error LNK2001: unresolved external symbol _UpdateTheWindowAndCheckForEvents

    2.
    test_one.obj : error LNK2001: unresolved external symbol _InitializeAWindowPlease

    3.
    LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

    4.
    Debug/test_one.exe : fatal error LNK1120: 3 unresolved externals

    please help me...why such errors are there.....

    Thanks!
    Hello there,
    You have taken this code from the opengl programming guide presumably. There is no such function in opengl as InitializeAWindowPlease(); or UpdateTheWindowAndCheckForEvents(); These functions are given here as place holders. Depending upon your OS, you have to do the opening and closing of windows and other os related stuff in plavce of these place holders. If you use glut, window handling will be dealt with by glut itself otherwise you would have to give WinMain handler yourself. Have a look at nehe's turoials at http://www.nehe.gamedev.net or Nate robins turotials at http://www.xmission.com/~nate/opengl for help on this. Check both glut and win32 stuff. thanx

  3. #3
    Junior Member Regular Contributor
    Join Date
    Aug 2004
    Location
    Angers, France
    Posts
    248

    Re: Why my code can not be compiled :(

    Don't forget the programming guide, th is simply the best method to visualise how-to-render-a-thing/effect
    The .Product will make you .Believe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •