Another option is to grab the glut libs from Nvidia's CG install. I grabbed Cg from:
https://developer.nvidia.com/cg-toolkit-download
I selected the 'source' options (library and header files and x64
compile) only. This is only to get the glut libraries from cg. Go into
the "Cg" program files directory. lib.x64, include and bin have the
files you want. Now to put them in the right place!
To compile against the windows bound opengl implementation in cygwin,
I first installed the mingw compiler using cygwin's setup program linked below.
In particular, I wanted 64 bit so I chose to install:
Devel | mingw64-x86_64-gcc-g++
from
http://cygwin.com/install.html
The next step is to install glut into the proper locations for usage.
I grabbed the dll/lib/and .h from Nvidia's CG (see the aside) but I've
relinked them:
Update: Editing my path wasn't required at all, but I left this here in case someone may need it.
However, I
had to add the /bin location to my path. I do this by editing my path
directly in my .bashrc
I also often put my home bin in as well, so I'll show all three options here. Type this one one line:
export PATH=/home/Ramsey/bin:/usr/x86_64-w64-mingw32/bin:/usr/x86_64-w64-mingw32/sys-root/mingw/bin:/usr/x86_64-w64-mingw32/include:$PATH
I also needed to put glut in the right places. In my case, I put them
in the mingw toolchain in the /include, /lib, and /bin locations.
In my second time through, I placed them in /usr/lib /usr/include and /usr/bin (with a copy to C:/windows/system)
I placed my glut32.dll in C:/windows/system (There are actually
several options for this location, but this is the option I went
with.)
Second: I put glut.h in my mingw toolchain include directory. In my case this was:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/GL
Last: copy the glut32.lib to your toolchain lib However, rename this file libglut32.a
cp glut32.lib /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libglut32.a
Now you can compile glut/gl programs using mingw g++ which is located in /bin
Update: It turns out that in my new update, I didn't run into any compilation warnings. I've included this just in case it is still relevant to others.
In this process, -Wall with mingw complained that a function is not used. In specific, this function:
on line 634 of glut.h
static int GLUTAPIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); }
To get rid of this warning you could simply comment out this line.
Another option is to compile with
-DGLUT_DISABLE_ATEXIT_HACK
or #define this variable outright in your main.
In addition, to get a stand-alone executable (that doesn't require
mingw or cygwin dlls), I used the -static keyword.
Here's an example of my final compile:
/bin/x86_64-w64-mingw32-g++.exe -Wall -static Vector.o String.o particles.cpp -lglut32 -lglu32 -lopengl32 -o wparticles
These are the top 3 lines of my Makefile:
OPT = -static -Wall
CC = /bin/x86_64-w64-mingw32-g++.exe
LINK = -lglut32 -lglu32 -lopengl32