Aim: to build and install in your home directory a library and and application.
The slides for this morning's lecture on Linux are available.
Download and install putty-ssh and connect to
lengau.chpc.ac.za using the username (studentNN) and password provided.
src directory to store the source.
Copy the zlip source code tar file from my home directory.
cp /home/student00/??? .
Fill in the ??? with the correct path and file name.
Move the tar file into the new directory:
mv zlib-1.2.8.tar.gz src/
Note that the version available is probably newer than 1.2.8 — modify these instructions accordingly.
Untar the file
cd src tar zxvf zlib-1.2.8.tar.gz
Load the correct environment variables using the tool “module”:
module load gcc/???
Fill in the correct information for the ??? above.
Prepare your own local directory structure:
cd ~ mkdir local cd local mkdir bin lib share include
Configure the compile environment:
cd zlib-1.2.8 ./configure --prefix=~/local
Compile zlib using the tool “make” (instructing it to install to your local directory):
Verify that everything is in
ls -R ~/local
zpipe.c file from my home directory (student00) into your
You should be able to work out what the commands are by now
zpipe.c file to change the line that reads
and change the name of the
zlib.h file in your
~/local/include directory to match.
Now compile the object file (ends in
gcc -c -o zpipe.o -I ~/local/include zpipe.c
This should find the
zzzlib.h file without errors.
gcccommand without the
-I ~/local/includeto what happens.
Now build the
gcc -o zpipe -I ~/local/include zpipe.c -L ~/local/lib -lz
The order of the command line options and arguments is important
The commands to link the library file must come after the commands to compile.
If there are no errors and
ls shows you a
zpipe file (in green) you are done.
You can test the new
zpipe program by compressing and then uncompessing a file.
./zpipe < test > test.z ./zpipe -d < test.z > test2 cmp test test2
There should be no difference between
Now it is inconvenient that you have to always be in the
src directory to use
zpipe or to have to always type the full path to it:
zpipe in your local execultable tree
cp zpipe ~/local/bin
To make sure that the shell can find
zpipe you need to include your
local/bin in the
PATH environment variable:
Now you need only type
zpipe to use it anywhere.
cd zpipe --help
To make sure that each time you login that the
PATH variable contains your
local/bin directory, just add the
export command to your
And add (or edit the existing line) to have:
PATH=$HOME/local/bin:$PATH export PATH