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 9 of 9

Thread: trouble compiling

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2004
    Posts
    7

    trouble compiling

    Hi there! Im pretty new at OpenGL programming but I have a basic question.

    I tried to compile the following code:

    #include "gl/OpenGLSB.h" // System and OpenGL Stuff

    /////////////////////////////////////////////////
    // Called to draw scene
    void RenderScene(void)
    {
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT);

    // Flush drawing commands
    glFlush();
    }

    /////////////////////////////////////////////////
    // Setup the rendering state
    void SetupRC(void)
    {
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
    }

    /////////////////////////////////////////////////
    // Main program entry point
    void main(int argc, char* argv[])
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(800,600);
    glutCreateWindow("Simple");
    glutDisplayFunc(RenderScene);

    SetupRC();

    glutMainLoop();
    }

    This resulted in error messsages such as:

    In function `main':
    [Warning] return type of `main' is not `int'
    [Linker error] undefined reference to `_imp__glClear'
    [Linker error] undefined reference to `_imp__glFlush'
    [Linker error] undefined reference to `_imp__glClearColor'

    etc. What's the problem???

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: trouble compiling

    Well, the warning is because you're violating the C++ rule that "main" must be declared as returning int. (Although you don't actually have to return one... don't ask.) The errors are because you aren't linking to the opengl import library (opengl32.lib for Win32). Check your project settings or makefile.

    cheers
    Mike

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2004
    Posts
    7

    Re: trouble compiling

    What is necessary to change under project settings?
    Im using the Bloodshed Dev C++ IDE and under project settings>Paramaters>Linker i pasted the following code:

    -mwindows -lglfw -lopengl32 -lglu32

    It has worked in previous projects.

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2004
    Posts
    7

    Re: trouble compiling

    OK, I've managed to figure out the problem with the linkers now and managed to compile. But that gave arose to another problem. I have trouble executing the file since the file OPENGL.dll is missing.

    Where can I get this file and where shall I place it??

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: trouble compiling

    Originally posted by rolandoo:
    It has worked in previous projects.
    With the same IDE, the same libs and the same "gl/OpenGLSB.h" header? Odd. -opengl32 is fine; it's what I use in my mingw makefile.

    The undefined reference error for "_imp__glClear" etc looks peculiar, because in my copy of libopengl32.a there's no such entry - looking at it in a hex editor, it only has "_glClear" and "__imp__glClear" (note the extra leading underscore).

    Hmmm... *scratches head*

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2004
    Posts
    7

    Re: trouble compiling

    No, maybe I havent used the same headears. In previous programs. Nevermind the file is now compiled but not executable.

    I'm not sure where to place the OPENGL.dll file??

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: trouble compiling

    Originally posted by rolandoo:
    I'm not sure where to place the OPENGL.dll file??
    Either in the same dir as your executable, or in the dir as opengl32.dll (normally C:\WINDOWS\SYSTEM32)

    Do be aware that opengl.dll is an ancient software-only SGI implementation and nobody really uses it on the Windows platform these days. I believe it'll patch calls through to opengl32.dll if hardware acceleration is available.

    So what happened with the link problems? Did you try -lopengl instead, or what? I'm surprised it was installed by default.

  8. #8
    Junior Member Newbie
    Join Date
    Nov 2004
    Posts
    7

    Re: trouble compiling

    I only added one part in the Linker field:

    -mwindows -lglfw -lopengl32 -lglu32 -lglut

    These linkers were not there by default, I read somewhere that you should when I tried some sample code.

  9. #9
    Junior Member Newbie
    Join Date
    Nov 2004
    Posts
    7

    Re: trouble compiling

    Ok, I still cant execute this very simple program. The source code is:

    #include "Common/OpenGLSB.h" // System and OpenGL Stuff
    /////////////////////////////////////////////////
    // Called to draw scene
    void RenderScene(void){
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT);
    // Flush drawing commands
    glFlush();
    }
    /////////////////////////////////////////////////
    // Setup the rendering state
    void SetupRC(void){
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
    }
    /////////////////////////////////////////////////
    // Main program entry point
    void main(int argc, char* argv[]){
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(800,600);
    glutCreateWindow("Simple");
    glutDisplayFunc(RenderScene);

    SetupRC();
    glutMainLoop();
    }

    I cannot execute because the file OPENGL.dll is missing. I downloaded this file and placed it under Windows/systems32 without success. Please help so that I can go on learning OpenGL

Posting Permissions

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