Resume Biography Gallery Digital Images Projects
Josh Grant
 
Example Using the SoGui Toolkits
January 2002

A common group of tools for developing portable software are autoconf and automake. They take care of all the tedious work that goes into creating a configure script and let you (the developer) focus on more in depth aspects of the configuration process.

Below I have provided a step by step How To for creating portable Open Inventor applications. (Another example can be found at the Marching Cubes page.) More than 95% of the hard work was done by the Systems in Motion group developing Coin3D. I am using all their autoconf macros for searching for OpenGL, Open Inventor by SGI, TGS, or Coin, etc. This example takes full advantage of the various windowing APIs currently available.

It has been tested on:
  • Linux using Coin with SoQt, SoXt, and SoGtk, and SGI's Open Inventor with their Xt Library
  • Irix using Coin with SoQt and SoXt, and SGI's Open Inventor with their Xt Library
  • Haven't got around to testing it on Windows using SoWin (if you get it to work tell me all about it please.)
The best way to learn this is to follow the below steps one by one, and ACTUALLY DO THEM!

If you are going to be compiling programs at CSIT, then first look at Setting Environment Variables at CSIT.
  1. create a directory named cube
    > mkdir cube
    
  2. CSIT users can copy over the template directory structure by executing the command
    > cptemplate cube
    
    outsider users can download the directory here. The cptemplate script takes as an argument the directory where the template files are to be stored. If the directory does not exist it will not create it.
  3. cd to the cube directory and type ls -l. There are several files needed by autoconf and automake in order to get this all this working. I am not going to explain each file, if you want to learn more about these refer to the manuals of autoconf and automake.
  4. Open the configure.ac file and change the top variables to fit this project
    # this will be the name of the
    # project (cannot have spaces)
    m4_define([PROJECT],      [cube])
    
    # the version number of the project
    # (e.g. 1.0)
    m4_define([PROJ_VERSION], [0.1])
    
    # an email address where users can
    # contact you, the developer.
    m4_define([SUPPORT_ADDR], [user@domain])
    
    ...
    
  5. Open the file src/main.cpp.in. This file is the template for creating src/main.cpp. After configure has been run config.status will be created containing several substitution variables (i.e. the type of Gui to use). src/main.cpp.in is the file you should edit when making changes for your program. NEVER MODIFY main.cpp, ALL CHANGES WILL BE LOST THE NEXT TIME config.status IS RUN.

    Add the following code to the makeScene() function.
    SoSeparator *root = new SoSeparator();
    
    SoMaterial *mat = new SoMaterial();
    mat->diffuseColor.setValue(0.0, 0.0, 1.0);
    root->addChild(mat);
    
    SoCube *cube = new SoCube();
    root->addChild(cube);
    
    return root;
    
  6. Open the file src/Makefile.am and change the variable noinst_PROGRAMS to the following.
    noinst_PROGRAMS = cube
    
    now change the variable progname_SOURCES to cube_SOURCES    automake needs to know which source files will be used to build the program cube.   src/Makefile.am should now look like this.
  7. Make sure you are currently at the root of the project directory (for this example cube), and at the Unix prompt type
    > aclocal -I cfg/m4
    > autoconf
    > autoheader
    > automake
    
  8. Now it is time to configure the project for a Gui toolkit. The default (no arguments) on Unix systems is for configure to find SGI's version of Open Inventor and their Xt library, but others can be specified by adding an argument --with-soGUI Where GUI is either xt, qt, gtk, or win. To configure with Qt type
    > ./configure --with-soqt
    
    if all went well then the configure script should create the needed Makefiles and you can type
    > make
    
    several lines of text will be output by make, but as long as there aren't any error messages everything is fine.
  9. To execute the program type
    > src/cube
    
  10. Now that you have the program working you can easily create a tar.gz file for the web by typing
    > make dist
    
    This command creates a separate directory under oivtest and copies all the files needed to configure and compile the project. Then it tars and gzips them into one file named cube-0.1.tar.gz. This is an excellent way to maintain different working versions of your code.
 

Josh Grant > Projects > Open Inventor > Example Using the SoGui Toolkits

Comments or questions about this page can be addressed to Josh Grant at grant@cs.fsu.edu