View Full Version : Getting myfirst openGL to work

12-21-2006, 02:01 AM

I just typed my first C simple program with (freeglut3 and freeglut3 developer versions 2.4.0-4) under Ubuntu Dapper Drake. The code comes from graphics textbook.

The problem I have, after loading the proper inlcude files (freeglut_std.h and freeglut_ext.h) is that I get lots of undefined refernces "glutInitWindowPosition, glBegin, GlMatrixMode, ...." practically all OpenGL keyword in the program.

As if for some reason, the header files are not used.

Any clue?


12-21-2006, 02:08 AM
Command line in order to compile and link your program:

gcc my_program.c -o my_program -L /usr/X11R6/lib -lglut -lGL -lGLU -lXmu

where -L /*** gives the correct location of some libraries like X ones or even GL* ones.

I don't know freeglut, but shouldn't you include glut.h instead of free*.h ?

12-21-2006, 07:41 AM
Hello and Thanks. Things are far better now. However, I got the message when running the program:
" freeglut (./graphics): OpenGL GLX extension not supported by display ':0.0' "

graphics is the program name.

Here is my program:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/freeglut_std.h>
#include <GL/freeglut_ext.h>

void init(void)
glClearColor (1.0,1.0,1.0,0.0);
glMatrixMode (GL_PROJECTION);
gluOrtho2D (0.0, 200.0,0.0,150.0);

void lineSegment(void)



void main(int argc, char** argv)
glutInit(&argc, argv);
// glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("An Example OpenGL program");


12-21-2006, 07:51 AM
What does 'glxinfo' returns ?
What graphic card do you have ?
What driver do you use (in /etc/X11/XF86Config or in /etc/X11/xorg.org depending on which X you are running) ?

The program you show is well, I also have searched and found that the headers you use are also well but the fact that including glut.h is somewhat better (it only include the std part not the ext one). But I guess this won't solve your problem.

12-21-2006, 08:00 AM
Forgot to tell:

do you have a line such as:

Load "glx"in your Section "Modules" ? If not you might add it.

12-21-2006, 08:37 AM

what do you mean by the section "Modules"? Where?


12-21-2006, 10:09 AM
in one of the files jide mentioned- /etc/X11/xorg.conf (or maybe /etc/X11/XF86config). the module section could look like this:

Section "Module"
Load "dbe"
Load "type1"
Load "freetype"
Load "extmod"
Load "glx"
Load "v4l"

12-21-2006, 10:02 PM
I am using an old toshiba Tecra notebook with NVIDIA GeForce4 420 GO. The driver is "nv".

"Load glx" was there already.

Sorry, but can you explain how can I get you the "glexinfo".

12-21-2006, 10:53 PM
glxinfo, not glexinfo. it is a command-line tool. open a console and just type glxinfo.

12-22-2006, 05:23 AM
Here is the output:

$ glxinfo
name of display: :0.0
Xlib: extension "GLX" missing on display ":0.0".
Xlib: extension "GLX" missing on display ":0.0".
Xlib: extension "GLX" missing on display ":0.0".
Error: couldn't find RGB GLX visual

visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav
id dep cl sp sz l ci b ro r g b a bf th cl r g b a ns b eat
Xlib: extension "GLX" missing on display ":0.0".
Xlib: extension "GLX" missing on display ":0.0".
0x21 16 tc 1 0 0 c . . 0 0 0 0 0 0 0 0 0 0 0 0 0 None
Xlib: extension "GLX" missing on display ":0.0".
Xlib: extension "GLX" missing on display ":0.0".
0x22 16 dc 1 0 0 c . . 0 0 0 0 0 0 0 0 0 0 0 0 0 None

12-22-2006, 05:27 AM
i think "nv" is an unaccelerated open source nvidia driver. did you download and install the actual nvidia driver from their homepage? if you haven't already, go for it now. if you already have, try to remove the 'Load "nv"' line from the xorg.conf file and restart the x server.

12-22-2006, 05:34 AM
You don't need the official nvidia drivers for glx to work. Why it doesn't actually work ? I must admit I still wonder. I will try to check it this evening.

Check the X logs (in /var/log/X*.log) for lines about glx. It should say why it can't load glx at startup.

For the point about Load "nv", if you have the nvidia drivers it should be Load "nvidia" instead.
Of course, and for better performances, and even for simplicity, you could install the official nvidia drivers. It's not hard to install them and will surely avoid that issue with your current not working glx.

12-23-2006, 01:02 PM
Hello all,

Thanks, it is working now.

I think the 'nv' is not the accelerated adapter driver that is required. The NVIDIA GeForce4 420 GO that I have is a legacy graphic processor that needs the legacy accelerated driver (Most Recent Driver: 1.0-7184)- NVIDIA site.

I downloaded the NVIDIA legacy driver support package from ubuntu and changed the driver from 'nv' to 'nvidia'.