OpenGL beginner issues
I am trying to compile some OpenGL source code and keep getting errors. I am running RH 7.0 and appear to have all of the libraries. Here are the errors. Could someone please let me know what I am doing wrong. I am about to pull out my last remaining strand of hair.
Thanks
LEPP
OpenGL]$ g++ test.cpp
/tmp/cccI2Dbq.o: In function `display(void)'':
/tmp/cccI2Dbq.o(.text+0xf): undefined reference to `glClear''
/tmp/cccI2Dbq.o(.text+0x29): undefined reference to `glColor3f''
/tmp/cccI2Dbq.o(.text+0x36): undefined reference to `glBegin''
/tmp/cccI2Dbq.o(.text+0x4d): undefined reference to `glVertex3f''
/tmp/cccI2Dbq.o(.text+0x64): undefined reference to `glVertex3f''
/tmp/cccI2Dbq.o(.text+0x7b): undefined reference to `glVertex3f''
/tmp/cccI2Dbq.o(.text+0x92): undefined reference to `glVertex3f''
/tmp/cccI2Dbq.o(.text+0x9a): undefined reference to `glEnd''
/tmp/cccI2Dbq.o(.text+0x9f): undefined reference to `glFlush''
/tmp/cccI2Dbq.o: In function `init(void)'':
/tmp/cccI2Dbq.o(.text+0xb7): undefined reference to `glClearColor''
/tmp/cccI2Dbq.o(.text+0xbf): undefined reference to `glLoadIdentity''
/tmp/cccI2Dbq.o(.text+0xe8): undefined reference to `glOrtho''
/tmp/cccI2Dbq.o: In function `main'':
/tmp/cccI2Dbq.o(.text+0x107): undefined reference to `glutInit''
/tmp/cccI2Dbq.o(.text+0x114): undefined reference to `glutInitDisplayMode''
/tmp/cccI2Dbq.o(.text+0x129): undefined reference to `glutInitWindowSize''
/tmp/cccI2Dbq.o(.text+0x138): undefined reference to `glutInitWindowPosition''
/tmp/cccI2Dbq.o(.text+0x148): undefined reference to `glutCreateWindow''
/tmp/cccI2Dbq.o(.text+0x15d): undefined reference to `glutDisplayFunc''
/tmp/cccI2Dbq.o(.text+0x165): undefined reference to `glutMainLoop''
here is the code. I just copied this code from Addison-Wesley OpenGL Programming Guide.
Sorry
#include
#include
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);
/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f (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();
/* don''t wait!
* start processing buffered OpenGL routines
*/
glFlush ();
}
void init (void)
{
/* select clearing (background) color */
glClearColor (0.0, 0.0, 0.0, 0.0);
/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(display);
glutMainLoop();
return 0; /* ISO C requires main to return int. */
}
Sorry
#include
#include
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);
/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f (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();
/* don''t wait!
* start processing buffered OpenGL routines
*/
glFlush ();
}
void init (void)
{
/* select clearing (background) color */
glClearColor (0.0, 0.0, 0.0, 0.0);
/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(display);
glutMainLoop();
return 0; /* ISO C requires main to return int. */
}
I did include the headers. They did not post because of the html tags and I forgot the code for greater than and less than.
This problem you''re having looks to be related to linking... does your project or whatever know it is supposed to link to opengl32.lib and glut32.lib? Can you set that information somewhere in the settings, or in a makefile or sumfin? (sorry, but I''ve never used RH... MSVC user, guilty as charged )
This would explain why the object files don''t know how to resolve the OpenGL function names.
This would explain why the object files don''t know how to resolve the OpenGL function names.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement