Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up OpenGL on Fedora

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.

like image 854
ffledgling Avatar asked Feb 20 '12 03:02

ffledgling


1 Answers

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.

like image 164
Timothy Jones Avatar answered Sep 24 '22 06:09

Timothy Jones