Ramsey's Code Blog

The idea of these pages is to post about tips and tricks that I've used along the way.

10.28.14 | Compiling against the windows windowing system instead of X11
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:

glut32.dll | glut32.lib | glut.h


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

While I don't follow his guidelines exactly (there are some things that are much easier in my method), some useful information was found from: http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/
10.30.14 | GLUI working with mingw
Update: declaring CXX in the makefile appropriately makes it so this step is not necessary. I still did this and am keeping this configuration currently.

At this point, compilation was still tanking. The makefile included CC and CXX variables, but the object files were still being compiled with the gnu c++. At this point, I decided to simply move my mingw compiler to be g++. I intend to use this from now on and so it'll fine to store the old gnu compiler elsewhere. So, in /bin I moved g++.exe to oldg++.exe and I copied /bin/x86_64-w64-mingw32-g++.exe to /bin/g++.exe
The first step in this process was simply grabbing glui. A bit dated but I grabbed it from here:

http://glui.sourceforge.net

The libglui Makefile still relied on X11 to compile, and used the gnu archiver. I relinked the libraries and altered the compilers. I updated the ar and added an ar option to use the mingw toolchain ar as well and removed the link dependencies that relied on X and X extensions. I've included my final Makefile and the library libglui.a and the header glui.h

At this point, execute the make and move libglui somewhere useful.
cp lib/libglui.a /usr/x86_64-w64-mingw32/sys-root/mingw/lib/.