Author Topic: opengl linker errors  (Read 7777 times)

Offline katerpeter

  • Single posting newcomer
  • *
  • Posts: 6
opengl linker errors
« on: June 25, 2006, 01:15:01 pm »
i just downloaded code::blocks v1.0rc2 because the new Dev-c++ jus' pissed me off. i tried to compile my opengl code and it gave me these three errors:

undefined reference to `__glutInitWithExit@12'
       "            "       to `__glutCreateWindowWithExit@8'
       "            "       to `__glutCreateMenuWithExit@8'

here's my source file:
Code: cpp
#include <GL/glu.h>
#include <GL/glut.h>

void display (void){
     glClear(GL_COLOR_BUFFER_BIT);
     glColor3f(1,1,1);
     glBegin(GL_TRIANGLES);
     glVertex3f(2,2,0);
     glVertex3f(2,-2,0);
     glVertex3f(-2,-2,0);

     glVertex3f(2,2,0);
     glVertex3f(-2,2,0);
     glVertex3f(-2,-2,0);

     glColor3f(1,0,0);
     glVertex3f(0,4,0);
     glVertex3f(2,2,0);
     glVertex3f(-2,2,0);

     glVertex3f(0,4,0);
     glVertex3f(0,8,0);
     glVertex3f(-2,6,0);

     glVertex3f(0,4,0);
     glVertex3f(0,8,0);
     glVertex3f(2,6,0);

     glColor3f(0,1,0);
     glVertex3f(-4,0,0);
     glVertex3f(-2,2,0);
     glVertex3f(-2,-2,0);

     glVertex3f(-4,0,0);
     glVertex3f(-6,2,0);
     glVertex3f(-6,-2,0);

     glVertex3f(-6,2,0);
     glVertex3f(-6,-2,0);
     glVertex3f(-8,0,0);

     glColor3f(0,0,1);
     glVertex3f(-2,-2,0);
     glVertex3f(2,-2,0);
     glVertex3f(0,-4,0);

     glVertex3f(0,-4,0);
     glVertex3f(0,-8,0);
     glVertex3f(-2,-6,0);

     glVertex3f(0,-4,0);
     glVertex3f(0,-8,0);
     glVertex3f(2,-6,0);

     glColor3f(1,1,0);
     glVertex3f(2,2,0);
     glVertex3f(2,-2,0);
     glVertex3f(0,4,0);

     glVertex3f(0,4,0);
     glVertex3f(6,2,0);
     glVertex3f(6,-2,0);

     glVertex3f(6,-2,0);
     glVertex3f(6,2,0);
     glVertex3f(8,0,0);
     glEnd();
}
void init (void) {
     glClearColor(0,0,0,0);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     glOrtho(-10,10,-10,10,0,0);
}
int main(char *argv[], int argc){
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(800,600);
    glutInitWindowPosition(0,0);
    glutCreateWindow("Triangles");
    init();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}}
Thanks in advance!!

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: opengl linker errors
« Reply #1 on: June 25, 2006, 02:28:03 pm »
Apparently, you did not add the glut library to your linker options.

Two things to note:

1. GLUT is quite old and abandoned for several years now. Although it is still possible to develop with GLUT, you might want to consider something else if you can. (freeglut if you need something as close as possible, otherwise you maybe want to look at GLEW).

2. Code::Blocks RC2, too, is quite old and outdated by now. You might want to consider using a nightly build before starting to work with RC2. The nightly builds are from the present development version and are a lot more stable and better usable. Also, RC2 stores its settings in the Windows registry, which we abandoned months ago.
If for no other reason, you may want to use a nightly build because you will lose the settings that you apply to RC2 if you ever update later.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

sethjackson

  • Guest
Re: opengl linker errors
« Reply #2 on: June 25, 2006, 04:07:19 pm »
You may want to loook at OGRE. :)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: opengl linker errors
« Reply #3 on: June 25, 2006, 06:25:39 pm »
You may want to loook at OGRE. :)
Erm... not seriously :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

sethjackson

  • Guest
Re: opengl linker errors
« Reply #4 on: June 25, 2006, 07:21:12 pm »
You may want to loook at OGRE. :)
Erm... not seriously :)

Welll. I have never used it. :lol: Just heard of it.... So do you mean it is not so great?

Offline katerpeter

  • Single posting newcomer
  • *
  • Posts: 6
Re: opengl linker errors
« Reply #5 on: June 25, 2006, 07:44:31 pm »
ok thanks, i found GLEW but I found out that I don't have the latsest OpenGL and my computer won't let me access OpenGL.org any suggestions? thanks again

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: opengl linker errors
« Reply #6 on: June 25, 2006, 07:50:00 pm »
It sure is a great 3D graphics engine. But you need a PhD in computer science and a week of time to figure out what to compile... :)

Ogre has a lot of great features and is certainly excellent for an experienced user. However, for someone who just wants to test out a few things with OpenGL, it is absolutely unusable in my opionion, because it is such a darn huge thing. You'll get swamped in features, and you'll spend more time figuring out how to use the cool features than doing what you actually wanted to do.

GLEW on the other hand, requires no special knowledge at all and builds from a batch script in well under 10 seconds. Of course it does not have three terrain managers to choose from as Ogre does, neither does it come with a virtual filesystem manager or texture and shader classes. It is just a small, lightweight toolkit for writing an OpenGL app, nothing more. The good thing about it is that it is simple, lightweigth, and it takes no time to set up.
Actually, the first time I built GLEW, I double-clicked the enclosed make.bat and went to get a coffee, expecting it would take a few minutes. Turning away, I said to myself "Ow sh**... I should have known this crap build script would not work" because the DOS window had already closed again. But in fact it had worked nicely, it just doesn't take that long ;)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: opengl linker errors
« Reply #7 on: June 25, 2006, 07:50:47 pm »
ok thanks, i found GLEW but I found out that I don't have the latsest OpenGL and my computer won't let me access OpenGL.org any suggestions? thanks again
Latest OpenGL means display driver or headers? Or import libs?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline katerpeter

  • Single posting newcomer
  • *
  • Posts: 6
Re: opengl linker errors
« Reply #8 on: June 25, 2006, 08:06:05 pm »
actually i think my opengl installer file is from about 1995, that's the latest dowlodable version i could find without opengl.org and all the tutorials i found worked with glut and gl and glu libraries.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: opengl linker errors
« Reply #9 on: June 25, 2006, 08:16:38 pm »
Both nVidia and ATI offer recent (2.0) versions of OpenGL with their display drivers and offer headers, libraries and everything else with their SDKs, too. The SDKs are available at developer.nvidia.com as well as developer.ati.com, and the display drivers are available from the respective "www" subdomains.

The extgl.h coming with nVidia/ATI's SDK may not be 100% current (most of the time, they're a few weeks or months old), but they are usually good enough for everybody.

If you want the bleeding edge, the extgl.h header can be obtained from opengl.org (don't remember the exact location, but Google will find it).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: opengl linker errors
« Reply #10 on: June 27, 2006, 02:22:52 pm »
It only occurred to me now that I've been saying "GLEW" all the time (funnily, none of the 110 people reading the thread noticed... :))

Of course, I meant to say "GLFW" all the time. GLEW is for loading extensions only, which is not what katerpeter was interested in.
GLFW offers window creation, mouse and keyboard input, and the like stuff with an OpenGL window (plus, it supports extension loading, too).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."