problem compiling code with OpenGL calls

Joe Krahn
Sun Sep 18 18:12:00 GMT 2005

William Wallace wrote:
> I trying to compile a simple .c program that I
> downloaded from I'm using the following to
> compile the program (works on my UNIX box...):
> gcc example.c -lglut -lGL -lGLU -L/usr/X11R6/lib -lX11
> -lXmu -lm
> I get a slew of compile errors, for every OpenGL api
> call..For instance:
> /cygdrive/c/DOCUME~1/XXXXXXXX/LOCALS~1/Temp/ccMTvQUj.o:example.c:(.text+0x2a):
> undefined reference to `_glClearColor@16'
> I noticed something a bit odd. The documentation
> states that /usr/include/GL should contain the files:
> glut.h and gl.h, but I ONLY have glut.h.
OpenGL is a bit confusing in Cygwin, because you can compile programs to 
use Win32 WGL or X11 GLX as your OpenGL provider. This is a case of 
using WIN32 libraries versus Cygwin libraries is useful, because GLUT 
provides all of the OS-dependent interface.

The Win32 headers are in /usr/include/w32api (included by default?) and 
are linked with -lOPENGL32. The X11 headers are under /usr/X11R6/include 
and are linked with flags as you describe above.

Joe Krahn

Unsubscribe info:
Problem reports:

More information about the Cygwin-xfree mailing list