tags:

views:

2508

answers:

4

Is it possible to compile and run OpenGL programs from under Cygwin? If yes, how?

+7  A: 

It is possible to compile and run OpenGL programs under Cygwin. I illustrate the basic steps here:

  1. I assume you know OpenGL programming. If not, get the Red Book (The OpenGL Programming Guide). It is mandatory reading for OpenGL anyway.

  2. I assume you have Cygwin installed. If not, visit cygwin.com and install it.

  3. To compile and run OpenGL programs, you need the Cygwin package named opengl. In the Cygwin installer, it can be found under the Graphics section. Please install this package.

  4. Write a simple OpenGL program, say ogl.c.

  5. Compile the program using the flags -lglut32 -lglu32 -lopengl32. (This links your program with the GLUT, GLU and OpenGL libraries. An OpenGL program might typically use functions from all the 3 of them.) For example:

    $ gcc ogl.c -lglut32 -lglu32 -lopengl32

  6. Run the program. It's as simple as that!

Ashwin
+1  A: 

I remember doing this once with some success, a few years ago, basically trying to cross compile a small Linux OpenGL C++ program. I do recall problems with Windows OpenGL drivers being behind the times (due to MS's focus on DirectX). I had NVidia OpenGL and DirectX drivers installed on my Windows system, but cygwin/g++ seemed to want to only use the Microsoft OpenGL DLLs, many years old, which do not have the latest support for all the ARB extensions, like shader programs, etc. YMMV.

Jared Updike
A: 

@Jared: Yes, there might be problems using extensions that are in OpenGL 1.2 and later (the prehistoric version that Windows ships with). I haven't tried anything but simple programs with Cygwin.

Ashwin
+1  A: 

If the above doesn't work (and it didn't for me), try the following (which did!)

gcc ogl.c -lglut -lglu -lgl

tumnus