LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-12-2004, 04:03 AM   #1
vihan
LQ Newbie
 
Registered: Mar 2003
Posts: 7

Rep: Reputation: 0
problem OpenGL - glut


Hi,
i have successfully installed glut and got a sample program to compile. The source code of the program(g.cc) is as follows :

[root@kkp opengl]# cat g.cc
#include<GL/gl.h>
#include<GL/glut.h>

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. */
}


Now when i compile the program i get the errors listed below :


[root@kkp opengl]# gcc g.cc
/tmp/ccAHnH5T.o(.text+0xf): In function `display()':
: undefined reference to `glClear'
/tmp/ccAHnH5T.o(.text+0x29): In function `display()':
: undefined reference to `glColor3f'
/tmp/ccAHnH5T.o(.text+0x36): In function `display()':
: undefined reference to `glBegin'
/tmp/ccAHnH5T.o(.text+0x4d): In function `display()':
: undefined reference to `glVertex3f'
/tmp/ccAHnH5T.o(.text+0x64): In function `display()':
: undefined reference to `glVertex3f'
/tmp/ccAHnH5T.o(.text+0x7b): In function `display()':
: undefined reference to `glVertex3f'
/tmp/ccAHnH5T.o(.text+0x92): In function `display()':
: undefined reference to `glVertex3f'
/tmp/ccAHnH5T.o(.text+0x9a): In function `display()':
: undefined reference to `glEnd'
/tmp/ccAHnH5T.o(.text+0x9f): In function `display()':
: undefined reference to `glFlush'
/tmp/ccAHnH5T.o(.text+0xb5): In function `init()':
: undefined reference to `glClearColor'
/tmp/ccAHnH5T.o(.text+0xc5): In function `init()':
: undefined reference to `glMatrixMode'
/tmp/ccAHnH5T.o(.text+0xcd): In function `init()':
: undefined reference to `glLoadIdentity'
/tmp/ccAHnH5T.o(.text+0xf6): In function `init()':
: undefined reference to `glOrtho'
/tmp/ccAHnH5T.o(.text+0x11b): In function `main':
: undefined reference to `glutInit'
/tmp/ccAHnH5T.o(.text+0x128): In function `main':
: undefined reference to `glutInitDisplayMode'
/tmp/ccAHnH5T.o(.text+0x13d): In function `main':
: undefined reference to `glutInitWindowSize'
/tmp/ccAHnH5T.o(.text+0x14c): In function `main':
: undefined reference to `glutInitWindowPosition'
/tmp/ccAHnH5T.o(.text+0x15c): In function `main':
: undefined reference to `glutCreateWindow'
/tmp/ccAHnH5T.o(.text+0x171): In function `main':
: undefined reference to `glutDisplayFunc'
/tmp/ccAHnH5T.o(.text+0x179): In function `main':
: undefined reference to `glutMainLoop'
/tmp/ccAHnH5T.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


i also tried using :
#gcc g.cc -lglut -lGL

it gives me :
cc1plus: warning: `lut': unknown or unsupported -g option
/tmp/cc04tCtz.o(.text+0x11b): In function `main':
: undefined reference to `glutInit'
/tmp/cc04tCtz.o(.text+0x128): In function `main':
: undefined reference to `glutInitDisplayMode'
/tmp/cc04tCtz.o(.text+0x13d): In function `main':
: undefined reference to `glutInitWindowSize'
/tmp/cc04tCtz.o(.text+0x14c): In function `main':
: undefined reference to `glutInitWindowPosition'
/tmp/cc04tCtz.o(.text+0x15c): In function `main':
: undefined reference to `glutCreateWindow'
/tmp/cc04tCtz.o(.text+0x171): In function `main':
: undefined reference to `glutDisplayFunc'
/tmp/cc04tCtz.o(.text+0x179): In function `main':
: undefined reference to `glutMainLoop'
/tmp/cc04tCtz.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
[root@kkp opengl]# gcc g.cc -lGL -glut
cc1plus: warning: `lut': unknown or unsupported -g option
/tmp/ccmrIIEr.o(.text+0x11b): In function `main':
: undefined reference to `glutInit'
/tmp/ccmrIIEr.o(.text+0x128): In function `main':
: undefined reference to `glutInitDisplayMode'
/tmp/ccmrIIEr.o(.text+0x13d): In function `main':
: undefined reference to `glutInitWindowSize'
/tmp/ccmrIIEr.o(.text+0x14c): In function `main':
: undefined reference to `glutInitWindowPosition'
/tmp/ccmrIIEr.o(.text+0x15c): In function `main':
: undefined reference to `glutCreateWindow'
/tmp/ccmrIIEr.o(.text+0x171): In function `main':
: undefined reference to `glutDisplayFunc'
/tmp/ccmrIIEr.o(.text+0x179): In function `main':
: undefined reference to `glutMainLoop'
/tmp/ccmrIIEr.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


ANY sample program i try i get similar errors. I don't know what i'm doing wrong. Somebody please help me.

Thanks again

-vihan
 
Old 04-12-2004, 04:11 AM   #2
vihan
LQ Newbie
 
Registered: Mar 2003
Posts: 7

Original Poster
Rep: Reputation: 0
further info for problem above

i am running Red Hat GNU/Linux 9.0

have done the glut install using glut-devel-3.7-8.i386.rpm and
glut-3.7-8.i386.rpm

if anybody can direct me to a good tutorial(one with basic sample programs) on glut(for Red Hat GNU/Linux) i'd be very grateful.
 
Old 04-12-2004, 08:43 AM   #3
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Quote:
#gcc g.cc -lglut -lGL

it gives me :
cc1plus: warning: `lut': unknown or unsupported -g option

...

[root@kkp opengl]# gcc g.cc -lGL -glut
cc1plus: warning: `lut': unknown or unsupported -g option
Are you sure you used -lglut for the first one? The error indicates that you used -glut, as you used in the second one.
 
Old 04-12-2004, 09:37 AM   #4
vihan
LQ Newbie
 
Registered: Mar 2003
Posts: 7

Original Poster
Rep: Reputation: 0
GLUT problems

thanks a lot for the prompt reply deiussum, i did miss 'g' while posting it . i still have the error with the -lglut and -lGL options, have given the output below. By the way have you tried programming in glut?

[root@kkp opengl]# gcc g.cc -lglut -lGL
/tmp/ccB5fXyj.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `gluErrorString'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `XGetExtensionVersion'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `XFreeDeviceList'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `XQueryDeviceState'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `gluNewQuadric'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `XListInputDevices'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `gluQuadricDrawStyle'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `cos'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `gluCylinder'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `sin'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `XFreeDeviceState'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `XOpenDevice'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `gluQuadricNormals'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `XmuLookupStandardColormap'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `XSelectExtensionEvent'
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libglut.so: undefined reference to `gluSphere'
collect2: ld returned 1 exit status


P.S : If there's ANYBODY out there who has successfully compiled glut programs(and gotten the desired output) please do reply.

Thanks again deiussum, i appreciate your help
 
Old 04-12-2004, 11:03 AM   #5
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Ok, now you are running into problems because you aren't linking in the GLU library, and some of the X libraries.

Also, there are some known problems with glut under RedHat. You might want to do a search on the Linux forums at http://www.opengl.org.

As a quick test, you can try adding the following libraries, though:

-lGLU -lXi -lXmu.

And yes, I've used glut. It's nice for quick little OpenGL apps, but for my final apps, I tend to use system specific calls to create the OpenGL windows.
 
Old 04-17-2004, 06:53 AM   #6
vihan
LQ Newbie
 
Registered: Mar 2003
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks a lot deiussum

i checked out the OpenGL GNU/Linux forum, i finally got a proper compile and the program works. Thanks a lot deiussum. i haven't got much experience in using library links in gcc, thanks to you and the guys at the OpenGL forum now i do. Thanks again.

-vihan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie to opengl/glut true_atlantis Programming 3 08-28-2005 08:39 PM
openGL, glut and lights on C++ poeta_boy Programming 0 08-02-2004 05:21 PM
[opengl+glut]Please help me hylke Programming 2 05-10-2004 02:16 AM
glut (Opengl kompilierung) snu *BSD 1 01-20-2004 05:15 PM
glut/mesa/openGL gurra Programming 1 10-10-2001 03:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration