cwar
May 21st, 2009, 10:47 PM
So I'm trying to compile a very simple OpenGL app in Ubuntu 9.04. The code is:
#include <GL/glut.h>
void mydisplay(){
glClear(GL_COLOR_BUFFER_BIT); //clear the color buffer
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main(int argc, char** argv) {
glutCreateWindow("simple");
glutDisplayFunc(mydisplay);
glutMainLoop();
}And when I try to compile using
gcc simple.cI get the following output in the terminal
/tmp/ccpoeTpT.o: In function `mydisplay':
simple.c:(.text+0xe): undefined reference to `glClear'
simple.c:(.text+0x1a): undefined reference to `glBegin'
simple.c:(.text+0x30): undefined reference to `glVertex2f'
simple.c:(.text+0x46): undefined reference to `glVertex2f'
simple.c:(.text+0x5c): undefined reference to `glVertex2f'
simple.c:(.text+0x72): undefined reference to `glVertex2f'
simple.c:(.text+0x77): undefined reference to `glEnd'
simple.c:(.text+0x7c): undefined reference to `glFlush'
/tmp/ccpoeTpT.o: In function `main':
simple.c:(.text+0x9b): undefined reference to `glutCreateWindow'
simple.c:(.text+0xa8): undefined reference to `glutDisplayFunc'
simple.c:(.text+0xad): undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
Obviously it isn't finding the openGL libraries. I have the following installed:
glutg3, libglut3-dev, freeglut3-dev, freeglut3
And any dependencies.
Anyone have any idea what I'm missing?
This is probably a very basic question, but I am very new to compiling in Ubuntu (and command line at all, used visual studio in windows up to this point) and even newer to openGL (I'm a student, just started the graphics class). I apologize if this is too easy, I tried searching the forums and google but was unsuccesful. Also, this is my first post here on these forums so also let me know if I am missing anything, posting in the wrong place or doing anything wrong.
Thanks!
#include <GL/glut.h>
void mydisplay(){
glClear(GL_COLOR_BUFFER_BIT); //clear the color buffer
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main(int argc, char** argv) {
glutCreateWindow("simple");
glutDisplayFunc(mydisplay);
glutMainLoop();
}And when I try to compile using
gcc simple.cI get the following output in the terminal
/tmp/ccpoeTpT.o: In function `mydisplay':
simple.c:(.text+0xe): undefined reference to `glClear'
simple.c:(.text+0x1a): undefined reference to `glBegin'
simple.c:(.text+0x30): undefined reference to `glVertex2f'
simple.c:(.text+0x46): undefined reference to `glVertex2f'
simple.c:(.text+0x5c): undefined reference to `glVertex2f'
simple.c:(.text+0x72): undefined reference to `glVertex2f'
simple.c:(.text+0x77): undefined reference to `glEnd'
simple.c:(.text+0x7c): undefined reference to `glFlush'
/tmp/ccpoeTpT.o: In function `main':
simple.c:(.text+0x9b): undefined reference to `glutCreateWindow'
simple.c:(.text+0xa8): undefined reference to `glutDisplayFunc'
simple.c:(.text+0xad): undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
Obviously it isn't finding the openGL libraries. I have the following installed:
glutg3, libglut3-dev, freeglut3-dev, freeglut3
And any dependencies.
Anyone have any idea what I'm missing?
This is probably a very basic question, but I am very new to compiling in Ubuntu (and command line at all, used visual studio in windows up to this point) and even newer to openGL (I'm a student, just started the graphics class). I apologize if this is too easy, I tried searching the forums and google but was unsuccesful. Also, this is my first post here on these forums so also let me know if I am missing anything, posting in the wrong place or doing anything wrong.
Thanks!