Installing Libraries: A Lab Exercise

Installing Libraries A Lab Exercise

A number of examples in this book make use of classes found in one of the libraries that were written for this book. The source code for these classes is available for download.[4] In the HTML version of this book, the class names are all hyperlinked to API docs.[5] Here you learn how to download and install these extra classes.

[4] http://oop.mcs.suffolk.edu/dist

[5] http://oop.mcs.suffolk.edu/api

Instructions for installing libraries on a *nix platform for use with the book examples follow.

7.4.1. Fixing the Linker Path

On a *nix platform a shell script is generally used to define environment variables. Example 7.2 shows a bash script that handles the job.

Example 7.2. src/bash/env-script.sh

export CPPLIBS=$HOME/cs331/projects/libs export QTDIR=/usr/local/qt export LD_LIBRARY_PATH=$QTDIR/lib:$CPPLIBS export PATH=$QTDIR/bin:$PATH

You can run this script by typing one of the following commands:

source env-script.sh  

or

. env-script.sh  

Notice the dot (.) at the beginning of the second version. In the bash shell, the dot is equivalent to the command, source.

If you want to make sure that these environment variables are automatically set at the start of each shell, you can source the script from ~/.bashrc, which runs automatically whenever bash starts.

Hamish Whittal has put together a very nice online guide to shell scripting at http://learnlinux.tsf.org.za/courses/build/shell-scripting.

Категории