Let's consider the following program and try to compile it under Cygwin:
#include <GL/glut.h>
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glLoadIdentity();
}
It compiles and runs just fine. -I/usr/include/opengl
seems to be terribly important.
g++ -I/usr/include/opengl -I../include/cygwin -L../lib/cygwin test.cpp -o test.exe -lglut32 -lglu32 -lglew32 -lopengl32
Now,
#include <GL/glew.h> // from newest NVIDIA SDK
#include <GL/glut.h>
int main(int argc, char** argv)
{
glewInit();
glutInit(&argc, argv);
glLoadIdentity();
}
compiled by
g++ -I/usr/include/opengl -I../include/cygwin -L../lib/cygwin test.cpp -o test.exe -lglut32 -lglu32 -lglew32 -lopengl32
fails. How to build the second application?
First
There are several ways to build glew by from NVIDIA SDK: by VS, by cygwin, by cygwin with -D_WIN32. I also tried cygwin build of original glew from source.
VS build gives
/cygdrive/c/DOCUME~1/kelebron/LOCALS~1/Temp/ccErbecl.o:test.cpp:(.text+0xa8): undefined reference to `_glLoadIdentity'
collect2: ld returned 1 exit status
cygwin builds give many
../lib/cygwin/glew32.lib(glew.o):glew.c:(.text+0x38e): undefined reference to `_glXGetProcAddress'
and cygwin with -D_WIN32 does not compile at all (I was slightly motivated by this post).
Second
There seem to be two ways to link with OpenGL
with -L/lib/w32api
or with -L/usr/X11R6/lib -lX11 -lXi -lXmu
But, the -L directives do not change anything. I've got /usr/lib/w32api/libopengl32.a, but may be missing the X11 version (/usr/X11R6/lib/libGL?). What package should I include into Cygwin? I've installed all starting with libGL (not only...).