Getting started with openGL on ubuntu11.10

Hi,

I am banging my head against a wall right now. This must be the 5th day that I read everything up to chapter 2 in the redbook, tried to get example 1-2 (the hello world example) to work, failed and searched the internet for hours. Your help will be greatly appreciated.

I’m using ubuntu11.10 as OS. I have done a ‘sudo apt-get install’ of almost anything I found in forums and since I don’t get any complaints anymore about missing libraries. I think everything is installed.

In the header I include:
#include <GL/gl.h>
#include <GL/glu.h>
As I understand the redbook I don’t need to include freeglut.h, glx.h, X11.lib, etc., but I have tried all of them.

I compile like:
gcc -lGL -lGLU -lglut hello.c
I have tried every other combination of flags I could find on the forums, but it still doesn’t work it just gives me different error messages.

Does anyone have openGL working in ubuntu11.10. How do you do this?

Thanks in advance,
Arjen Stap

Apologies for shilling my own stuff, but you could try using the Unofficial OpenGL SDK. It has a Linux build, and I do test releases on Ubuntu.

Assuming you have the required packages installed:

Header includes:


#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

Then to compile/link a C++ program:


g++ -o tst tst.cpp -lglut -lGLU -lGL

For C programs, use gcc instead of g++. If problems, post the compile or link error you’re getting.

Thanks Dark Photon!

That works. My error was simply that I had the flags in front of the file I wanted to compile. I just got lost with all the different combinations of includes and flags I have seen and never even checked whether the position of the flags mattered.

Thanks a million!

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