This document describes how to setup Glut / FreeImage for compiling your applications for COSC 3P98. For the following tutorial you need the Load.c example program, a sample image in tiff format named img.tif. Download these files and jump to the category applicable to your setup.
Note that you may use Glut or FreeGlut (a version of Glut that is being maintained here). You will need to change the names of the DLL's and Header files according to which version you use.
Note: For your convenience, we have preconfigured a Visual Studio solution that automatically takes care of all the dependencies. This will be your best option as it enables you to quickly get up and running with Glut and FreeImage. Nevertheless, it is also a good idea to become familiar with configuring the libraries manually in case something goes wrong.
The preconfigured Visual Studio solution
Download the zip archive 3P98-C-Template.zip (C) (or 3P98-2021-Template.zip (C++)) and unzip the archive. This solution was created using Visual Studio 2021. Just open the solution file (3P98-2021-Template.sln) and write your code in the file "Source.c". Don't forget to include the necessary header files (eg. freeglut.h, freeimage.h, etc.). Hit F5 and the project should build and run automatically.
Since glut and freeimage are not installed in the COSC labs, it is preferable to use the preconfigured Visual Studio solution above for your assignments, so that you will be able to run them on lab computers. The old instructions for installing the libraries and setting up a project to use them is included on a separate page here.
In the lab (MCJ 310), glut and freeimage are already installed and hence you can skip to step 2. If you're installing on your own computer start with step 1.
Depending on your distribution this part of the installation may vary. It is usually best to use your distribution's package manager if it has the libraries in it rather than downloading the libraries from their web sites. The following steps are tailored to Ubuntu (or any other Debian-based) Linux but will likely just need slight modifications to work in other distributions.
Run the following command to download and install the FreeImage and Glut libraries.
For more recent versions of Debian-based distros, you might want to use freeglut instead of libglut. The command bellow will install freeglut3
After this, the libraries (and any dependencies) will be installed to the appropriate locations.
When you are compiling your application, you must tell the compiler that you are using OpenGL, Glut, FreeImage, etc. This is done using the -l (lowercase "L") flag in most compilers. For example, if you wanted to compile Load.c you would run the following:
On Ubuntu:
If you installed freeglut use this command:
On the lab computers:
After it compiles you can then run the program by typing:
To run the Load.c example program you need to place or create img.tif in the current directory.
Setting up Glut / FreeImage in Microsoft Visual Studio
Setting up Glut / FreeImage in Linux
Step 1 - Installing the libraries
Ubuntu (Or any Debian based) Linux
sudo apt-get install libglut3-dev libfreeimage-dev
sudo apt-get install freeglut3-dev libfreeimage-dev
Step 2 - Compiling your program
gcc Load.c -o load -lglut -lfreeimage
gcc Load.c -o load -lfreeglut -lfreeimage
gcc Load.c -o load -lGL -lGLU -lglut -lfreeimage -lX11
./load