Compiling an Application

There are two ways to compile VR Juggler applications: from the command line or with Microsoft Visual Studio. Compiling an application on the command line requires the use of GNU make (often installed as gmake) so that it will work on all supported platforms including Win32. Using Microsoft Visual Studio will only work on Win32.

Compiling from the Command Line

All the sample programs in $VJ_BASE_DIR/share/vrjuggler/samples use the same basic steps to compile unless otherwise noted. Always refer to the top of the sample application's Makefile for information that may be specific to building that application. In general, though, all applications' makefiles require the GNU version of the make(1) utility, sometimes installed as gmake.

The example used here will be the MPApp tutorial application found in $VJ_BASE_DIR/share/vrjuggler/samples/OGL/simple/MPApp. It is an OpenGL-based application that will compile and run on all platforms supported by VR Juggler. Begin by changing into the directory $VJ_BASE_DIR/share/vrjuggler/samples/OGL/simple/MPApp in a command shell.

To compile MPApp, simply enter the following:

% gmake

The compile process will then begin. As noted above, the use of GNU make is required to use the distributed makefiles. With Cygwin, GNU make is simply make. If you have your system set up properly, it will complete with an executable MPApp file (or MPApp.exe on Win32) in the directory. Now that you have a program compiled, it is time to learn how to run it. (Readers who are not using Visual Studio can skip ahead to Chapter 5, Running a VR Juggler Sample Program.)

Compiling Using Microsoft Visual Studio

Note

Remember that the Netscape Portable Runtime (NSPR) is required to use VR Juggler on Windows. Its DLL directory must be in your path (via the PATH environment variable) for proper application execution. The NSPR can be downloaded from the NSPR home page. If the pre-compiled VR Juggler dependencies are installed, then NSPR is already available.

All OpenGL sample applications are shipped with pre-configured Microsoft Visual C++ projects. This is done to help new users get started with compiling VR Juggler applications and to give experienced Visual Studio users a starting place for their application development. To use the workspace for the MPApp application, begin by opening the folder containing the source code and double-clicking on MPApp.vcproj.

Figure 4.1. Selecting the Visual C++ Project File

Selecting the Visual C++ Project File

Visual Studio will open, and the MPApp project will be loaded. The unexpanded class view will appear as shown in Figure 4.2, “MPApp Project” when Visual Studio first loads.

Figure 4.2. MPApp Project

MPApp Project

In some cases, it may be necessary to change the default project properties. The project properties dialog can be opened in several ways. For example, right-clicking on the project name in the Solution Explorer brings up the menu shown in Figure 4.3, “Project Menu”. We are interested in changing the project's properties, so we select the Properties item from the popup menu.

Figure 4.3. Project Menu

Project Menu

Under the MPApp project settings, the path(s) to the VR Juggler C++ dependencies must be filled in. This means setting paths to find headers and libraries. All the Visual C++ project files shipped with VR Juggler refer to the VR Juggler C++ dependency installation via the VJ_DEPS_DIR environment variable. If this is not set or cannot be used, the paths must be filled in manually.

Once the program properties are set, compile the application. Under the Build menu, choose the Build MPApp item as shown in Figure 4.4, “Build MPApp.exe”. Visual C++ will compile the application, and if you have everything configured properly on your computer, the compiling will complete successfully.

Figure 4.4. Build MPApp.exe

Build MPApp.exe

For the remainder of this book, much of the discussion will concentrate on running applications from the command line rather than from the Visual Studio GUI. Readers can follow whichever method they prefer.