UM EECS 487

Building OpenGL/GLFW Apps

on:

Sample code: the sample Makefile and source code build a simple line drawing application and runs on Linux, Mac OS X, and Windows platforms. You can also try out some examples with buffer objects and shaders.

For instructions on how to build GLUT programs, please refer to the course note Building OpenGL/GLUT Programs. Please let me know if you have any correction or addition. Thanks.

To find out how to specify command line options, add to header file search path, and link with libraries such as glew, expat, jpeg, and png, see the course note on these topics.

Linux:

version: Ubuntu 14.04.1 LTS (Trusty Tahr), 12.04.5 LTS (Precise Pangolin)
gcc: 4.8.2, 4.6.3
Eclipse 3.7.2-1 (Indigo)

Mac OS X:

Yosemite 10.10.5, Mavericks 10.9.4
Darwin 14.5.0, 13.3.0
Xcode: 6.4, 5.1.1
gcc: 4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.66.0svn), 5.1 (clang-503.0.40) (based on LLVM 3.4svn)

Windows:

version: 8.1 Enterprise
Visual Studio 2013 version 12.0.30723.00 Update 3
.NET Framework version 4.5.51641

You have the option to build 32- or 64-bit apps. If your app requires a lot of memory, for example, if it loads large texture files, and you expect it to run on 64-bit machines with 4GB or more RAMs, you can opt to build a 64-bit app. For the apps we build in the course, 32-bit is sufficient.

Cygwin:

version: 1.7.31-3 (64 bit NT-6.3)
compiler tool chains:
  x86_64-pc-cygwin: gcc 4.8.3 (to generate 64-bit Win32 apps)
  i686-pc-cygwin: gcc 4.8.3 (to generate 32-bit Win32 apps)
  i686-pc-mingw32: gcc 4.7.3 (original MinGW to generate 32-bit Win32 apps)
  i686-w64-mingw32: gcc 4.8.3 (MinGW w64 to generate 32-bit Win32 apps)
  x86_64-w64-mingw32: gcc 4.8.3 (MinGW w64 to generate 64-bit Win64 apps)

Install Cygwin/X11 by downloading and running its
setup program. If you're installing 64-bit version, x86_64-pc-cygwin is the compiler toolchain, i.e., compiler, linker, archiver, etc. you get by default. As installed, Cygwin builds X11 (OpenGL/GLX) apps instead of native Windows (OpenGL/WGL) apps. Unfortunately GLX programs on Cygwin that use buffer object segfault on the call to glBindBuffer() and those that uses shaders segfault on the call to glCreateProgram() for me. I have also not been able to compile GLFW for Cygwin/X11 for lack of Xf86VidMode library. So we'll build WGL apps instead. On 64-bit Cygwin, you can choose to build either 32- or 64-bit apps. If you use static libraries, you can set up Cygwin to support both.

If you want to build 32-bit apps or you want to use the MinGW compiler toolchain instead of the Cygwin toolchain, use the Cygwin setup program to install them (see above for a brief summary of each):

Devel→cygwin32-gcc-g++
Devel→mingw64-x86_64-gcc-g++
Devel→mingw64-i686-gcc-g++
Devel→mingw-gcc-g++

The setup program will figure out, download, and install all necessary dependencies. Let YOUR_TOOLCHAIN be one of i686-pc-cygwin, i686-pc-mingw32, i686-w64-mingw32, or x86_64-w64-mingw32, which correspond to the above toolchains in order. The Win32 OpenGL and Microsoft GDI libraries corresponding to each toolchain should be installed in:

/usr/YOUR_TOOLCHAIN/sys-root/{usr,mingw}/lib/libopengl32.a
/usr/YOUR_TOOLCHAIN/sys-root/{usr,mingw}/lib/libgdi32.a

with the OpenGL include files in:

/usr/YOUR_TOOLCHAIN/sys-root/{usr,mingw}/include/GL

Be sure to add the path /usr/YOUR_TOOLCHAIN/sys_root/{usr,mingw}/bin, to your search path for binaries and dynamically linked libraries (dll), i.e. your environment PATH variable, in addition to /usr/YOUR_TOOLCHAIN/bin already mentioned above. (As such, you can only have one toolchain in use for a given PATH environment variable.)

References not cited:

Last updated: Sept. 16, 2015 by Sugih Jamin