• 11
• 9
• 10
• 9
• 10

# Starting OpenGL In Linux

This topic is 4541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

http://www.opengl.org/resources/faq/getting_started.html This page is confusing me. What do I need to start programming for OpenGL using C++ in Linux. It says I may need some Mesa OpenGL-Work-Alike... But I know my current configuration can run openGL apps just fine (Cedega tests for example). I assume I need an SDK of somesort... Otherwise I'm beginning with the all-to-famous NEHE tutorials :)

##### Share on other sites
if other GL apps work fine i think all is in order.

check /usr/include for GL headers. if they're not there then you will need them

just remember the includes and (if using gcc on command line) the relevant -l things.( i cant quite remember them... )

##### Share on other sites
Well I checked that directory and there are no includes files which start with GL or resemable anything like openGL.

I do know I have OpenGL up and running tho, Cedega demands an OpenGL test before running, it showed a window up and some gears turning, this ran at 1000fps on my system.

By relevant -l commands, care to elaborate?

Thanks,
Halsafar

##### Share on other sites
Quote:
 Original post by HalsafarWell I checked that directory and there are no includes files which start with GL or resemable anything like openGL.

They'd all be in a subfolder labeled GL (GL/gl.h, GL/glu.h, GL/glut.h are common ones)
Quote:
 By relevant -l commands, care to elaborate?

These tell GCC what to link. For example, if I wanted to do some programming using libglut.so, I'd comple using something like:
gcc -lglut example.cpp -o example

-L flags may also be necessary to specify where a library file is, for example:
gcc -L/usr/X11R6/lib -lX example_xwindows_program.cpp -o example

##### Share on other sites
i havent tested this, im under windows at the minute, but something like this

(if anyone does know, please post )

g++ -o program source.cpp -lGL -lGLU

the second one is if you use GLutilites.

i think theres one for the GLaux utilites but im not 100% sure...

##### Share on other sites
NeHe's tutorials mostly are targetted at wgl hence use user32 and are win32 gui apps.

But the principles apply, and many have been ported to Linux, with or without the use of SDL or something else.

The easiest way to get apps working is to use glut. glut is not really very good for games, but works.

The exact libraries you need to link a GL application might vary slightly, but the following works for me:

LIBRARIES = -lX11 -lXi -lXmu -lSDL -lGL -lGLU -lm
LIBDIR = -L/usr/X11R6/lib -L/usr/local/lib

Some of these are probably unnecessary. Don't use -LSDL if you're not using SDL.

Mark

##### Share on other sites
There seems to be a little debate, but it really isn't too complex.

If you need the gl library (which you most definitely do), then use:
#include <GL/gl.h>
-lGL
to the compiler flags. (If you link manually, then do it then)

If you need the glu library, use:
#include <GL/glu.h>
and
-lGLU

For glut:
#include <GL/glut.h>
-lglut

That's it for the OpenGL library. If you use additional libraries, then you have to include those too, of course.

##### Share on other sites
Well to be honest I'm not getting anywhere with this heh.
Its not the compiling, I just cannot find a tutorial which even answers my simple questions... Like how do I create the window, what do I use to do it... Well and I cannot compile any of the source I do find :)
missing gltk.h on most.

Edit:
Okay I need GLUT.... I cannot find the Linux download on the opengl main webpage... I can only locate the Win32 Source.

##### Share on other sites
What distro of linux are you using? I didnt have a problem getting GL up and running fine in Arch or Gentoo, some distros fiddle with where the files are put (SuSE..)

##### Share on other sites
I am using Mandriva 2006.
OpenGL is installed and all its headers are there.
I found GLUT, installed it.

All the headers exist in /usr/inclue/GL/.

Anything I plainly compile gives me tons of missing reference errors. Which is where I came back here to find the flags you guys dicussed.

None of them work, I've tried everything here and all I get is missing reference errors on every call to a GL or GLUT function. This leads me to believe I do not have the OpenGL Libraries... the Devel I guess. But I know opeNGL works, Mandriva 2006 has a test feature for it, and Cedega works 'kinda' well.