Getting myfirst openGL to work


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?


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 ?

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”);


What does ‘glxinfo’ returns ?
What graphic card do you have ?
What driver do you use (in /etc/X11/XF86Config or in /etc/X11/ 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.

Forgot to tell:

do you have a line such as:

Load "glx"

in your Section “Modules” ? If not you might add it.


what do you mean by the section “Modules”? Where?


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"

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”.

glxinfo, not glexinfo. it is a command-line tool. open a console and just type glxinfo.

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

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.

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.

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’.


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.