5

I've been trying to set up (Install and get the correct libraries) for my computer so I could start graphic programming.

I've visited the OpenGL site, and have found it unhelpful. I tried the Wikibooks' Setting up page, but that has install info specific to Debian and Debian like systems and I couldn't find the corresponding stuff for fedora.

I know C and python and would prefer to work in C if possible, I did find PyOpenGL.noarch and installed it using yum.

I looked up a couple of other sites and didn't find much but I managed to Install freeglut-devel

I checked and found the GL libraries in /usr/include/GL folder but when I try to run the following code{taken from the wikibooks site itself, so I'm assuming it works}:

#include <stdio.h> /* printf */
#include <GL/glut.h> /* glut graphics library */
/* 
* Linux c console program 
* gcc f.c -lglut
* ./a.out
* */
main(int argc, char **argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
   glutCreateWindow("red 3D lighted cube");
   printf("GL_VERSION = %s\n",glGetString(GL_VERSION) ); /* GL_VERSION = 2.1.2 NVIDIA      195.36.24 */

return 0; 
}

And when I do gcc -lglut filename.c

I get the following errors:

/usr/bin/ld: /usr/lib/gcc/i686-redhat-linux/4.6.1/../../../libglut.so: undefined reference to symbol 'glGetString'
/usr/bin/ld: note: 'glGetString' is defined in DSO /usr/lib/libGL.so.1 so try adding it to the linker command line
/usr/lib/libGL.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

And I have no Idea what to do.

A basic step-by-step procedure would be much appreciated but if any help is always welcome.

genpfault
  • 51,148
  • 11
  • 85
  • 139
ffledgling
  • 11,502
  • 8
  • 47
  • 69

1 Answers1

5

Try adding -lGL to the command line you use to compile it (that's what the error message is telling you to do).

This question also suggests that you'll need -lGLU as well.

Additionally, I would put the libraries after the source files that use them, so:

gcc filename.c -lglut -lGL -lGLU

Instead of:

gcc -lglut -lGL -lGLU filename.c 

There is some more information about why you get this message on fedora here, but the basic fix is to explicitly link the missing library.

Community
  • 1
  • 1
Timothy Jones
  • 21,495
  • 6
  • 60
  • 90
  • Be aware that OpenGL doesn't directly support glut. http://www.opengl.org/resources/libraries/glut/ – user732933 Feb 20 '12 at 03:40
  • I had to Install libGNEW gnew.i686 to get the -lGNEW working which was also needed for some of the examples but otherwise it worked. Thanks. :D – ffledgling Feb 20 '12 at 05:55