PDA

View Full Version : Getting started with openGL on ubuntu11.10



Aryeahn
02-24-2012, 08:43 AM
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

Alfonse Reinheart
02-24-2012, 09:32 AM
Apologies for shilling my own stuff, but you could try using the Unofficial OpenGL SDK (http://glsdk.sourceforge.net/docs/html/index.html). It has a Linux build, and I do test releases on Ubuntu.

Dark Photon
02-24-2012, 09:47 AM
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...

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.

Aryeahn
02-24-2012, 10:30 AM
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!