|
An Example
Alyssa is writing a ray tracer for her computer graphics
class. She wants to use the
SDL and
G3D libraries to handle the low-level graphics math and windowing for her.
At her school, SDL is installed for all users in the /usr
directory. She downloaded G3D and installed it in her
home directory.
Alyssa writes her code in several C++ and header files.
She plans to later reuse some of the code in a generic
3D library of her own and prefers to organize that
into a subdirectory. Now it is time to compile her
program and begin debugging it. First, she configures
two environment variables to tell iCompile where her libraries
are stored:
# Set the custom INCLUDE and LIBRARY directories
setenv INCLUDE /u/alyssa/g3d/include:/usr/include/SDL
setenv LIBRARY /u/alyssa/g3d/lib
|
(She'll probably put these two lines in her
.cshrc file so she doesn't have to type them
in every terminal window). To compile her ray tracer,
she just enters the project directory and runs iCompile:
# Build (and document, and run) the program
cd graphics/raytrace
icompile --doc --run
|
Alyssa used the doc option to
automatically create HTML documentation for her code using
Doxygen. The
run option automatically launches her program
if compilation succeeds.
With that one command, iCompile compiled all of her code
to object files and linked the object files to create an
executable named raytrace based on the parent
directory name. From the headers she included, iCompile automatically detected
that her program needed to be linked against SDL and G3D, which it located using her INCLUDE and LIBRARY environment variables.
iCompile also detected that
G3D requires the JPEG and zlib libraries and that her
program uses multiple threads and needs the pthreads
library. All of these were located in system directories
and linked appropriately.
|