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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-12-2004, 04:03 AM
|
#1
|
|
LQ Newbie
Registered: Mar 2003
Posts: 7
Rep:
|
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
|
|
|
|
04-12-2004, 04:11 AM
|
#2
|
|
LQ Newbie
Registered: Mar 2003
Posts: 7
Original Poster
Rep:
|
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.
|
|
|
|
04-12-2004, 08:43 AM
|
#3
|
|
Member
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895
Rep:
|
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.
|
|
|
|
04-12-2004, 09:37 AM
|
#4
|
|
LQ Newbie
Registered: Mar 2003
Posts: 7
Original Poster
Rep:
|
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
|
|
|
|
04-12-2004, 11:03 AM
|
#5
|
|
Member
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895
Rep:
|
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.
|
|
|
|
04-17-2004, 06:53 AM
|
#6
|
|
LQ Newbie
Registered: Mar 2003
Posts: 7
Original Poster
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:37 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|