Configuring OpenGL on Fedora

I am trying to configure (install and get the correct libraries) for my computer in order to start graphical programming.

I visited the OpenGL website and found it useless. I tried " Customizing the page , but it has installation information specific to Debian and Debian systems, and I could not find the appropriate material for fedora.

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

I looked at several other sites and did not find much, but I managed to install freeglut-devel

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

#include <stdio.h> /* printf */ #include <GL/glut.h> /* glut graphics library */ /* * Linux c console program * gcc fc -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 will be appreciated, but if any help is always appreciated.

+4
source share
1 answer

Try adding -lGL to the command line that you use to compile it (that the error message tells you).

This question also suggests that you will need -lGLU .

In addition, I would put the libraries after using the source files, so:

 gcc filename.c -lglut -lGL -lGLU 

Instead:

 gcc -lglut -lGL -lGLU filename.c 

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

+4
source

Source: https://habr.com/ru/post/1397359/