User Tools

Site Tools


workshops:hpcprac1

This is an old revision of the document!


Practical 1: Linux Shell

Aim: to build and install in your home directory a library and and application.

Slides

The slides for this morning's lecture on Linux are available.

Logging in

Download and install putty-ssh and connect to ranger.ace.chpc.ac.za using the username (schoolNN) and password provided.

Build and install zlib library

Create a src directory to store the source.

mkdir src

Copy the zlip source code tar file from my home directory.

cp /home/kcolville/??? .

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/

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/gcc-4.9.2/4.9.2

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):

make install

Verify that everything is in ~/local

ls -R ~/local

Build a simple application using your own zlib

Copy the zpipe.c file from my home directory into your src directory.

You should be able to work out what the commands are by now

Edit the zpipe.c file to change the line that reads

#include "zlib.h"

to

#include "zzzlib.h"

and change the name of the zlib.h file in your ~/local/include directory to match.

Now compile the object file (ends in .o):

gcc -c -o zpipe.o -I ~/local/include zpipe.c

This should find the zzzlib.h file without errors.

Try the gcc command without the -I ~/local/include to what happens.

Now build the zpipe executable

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.

/app/dokuwiki/data/attic/workshops/hpcprac1.1435496692.txt.gz · Last modified: 2021/12/09 16:42 (external edit)