Aide memoire to using the unix C++ environment for 3C59
Use of the Unix environement
Log on to WTS
To connect to socrates/solaris you will use an Exceed session. There
should be a session file set up to make a terminal window on the solaris
system. Exceed is accessed from the start->programs
menu on windows.
As soon as you are into solaris type
tcsh
this will put you in a better shell where useful features work (the
default shell is csh which is not very useful)
Some simple unix commands are
-
cd directoryName
// to change directory
-
cd ..
// to go back up one level
-
ls
// to list files in a directory
-
ls -l
// to list in a long form
-
mkdir newDirName // to
make a new directory under the one you are in
-
rm fileName
// to remove a file
-
rm -r dirName
// to remove a directory and everything in it (be CAREFUL)
-
cp file1 file2
// to copy file1 into file2
-
mv oldName newName // To rename a file
-
pwd
// to tell you what directory you are in
To use the emacs editor type
emacs
&
this version of emacs is fairly intuitive to use, so play around with
the menus.
Preparation for exercises
These instructions need to be followed once at the beginning of the course.
Directory structure
Make a directory structure (using mkdir) starting from either your top
directory or anywhere else you want if you are familiar with unix.
It should look like this:
......../oocourse/util/
/misc
/DotProduct/
/BankAccount/
/ComptonAnalysis/
/ComptonMC/
/ParticleGeneration/
/Complex/
Whenever you perform an exercise you will be told which of these directories
to use
Environment
Copy the file build.sh (available from the
course web pages) into the oocourse directory
Change directory to your home directory with
cd
~
Then type the following:
chmod
u+xw .cshrc
(dont miss out the . in .cshrc)
Start emacs and edit the file
~/.cshrc
Add the following line at the end of it:
alias build '~/oocourse/build.sh'
or wherever the path to your oocourse directory is
Building executable programs
using emacs and the command line
We will hopefully use the Workshop environment which ISD have set up. However
this is new and there may be some teething troubles. As a fall back (and
in any case for the early exercises) we can also use a much simpler procedure
from emacs or from a command line.
As example suppose we want to write , build and run a file called test.cpp
-
Edit your test.cpp file in emacs
and save it .
-
Go to the command line and move into the directory you are doing this exercise
(using cd ).
-
Type : build test
Note: you do not type the .cpp extention (you will get an error message
if you do)
This should compile your test.cpp file, and if successful make an executable
called test.exe
-
To run test.exe all you need to do is type on the command line:
test.exe
You can also do the same thing from within emacs. If you do then you will
have the added feature that it will enable you to step through errors easily.
-
Edit your test.cpp file in emacs
and save it .
-
From the tools menu select compile
-
This will ask you for a command at the bottom of the page. You delete whats
there and instead enter build test
-
Then hit CR and test.cpp will be comliped
-
If there are errors they will be displayed on a split screen. The
good bit is that if you now highlight an error and click the RH mouse button
on it, then the line with the error will be shown on the top screen.
-
When you fix an error and want to re-compile then just repeat the procedure
This should be enough to get you going with simple exercises.
Building executable programs using Workshop
These instructions to be added later