Introduction to the Unix Cluster. Node: Compiling Directories
Commands
Printing
Compiling
UNIX programmers generally use C as their main language, but
Fortran seems to be the perennial favorite at the lab. UNIX compilers
are also used as linkers (except on the Crays), so there is usually no
need to explicitly call the loader (ld).
The general format for compiling and linking two modules is as
follows (using fortran code as an example):
-
[lyman|6]
f77 -c file1.f
[lyman|7]
f77 -c file2.f
[lyman|8]
f77 -o outfile file1.o file2.o
The option c means `compile, don't link
', and the option o
links and specifies the name of the executable file (in this case
`outfile
'). To execute the program, just type its name:
outfile. To run the optimizer use option O, to keep
debugging information use option g (except on the Crays).
The following is a listing of some of the options we have
available for working with code:
-
f77 - standard UNIX fortran compiler, understands Fortran-77.
Expects source code filenames to end in `
.f
' or `.for
'.
-
cc - C compiler, expects source code filenames to end in
`
.c
'.
-
gcc - GNU project C and C++ compiler (v2.4). Also requires
that filenames end in `
.c
'.
-
make - maintains, updates, and regenerates related programs
and files. Useful for re-compiling and re-linking after
making small changes---make only updates the files that
are affected. gmake is the GNU version.
-
RCS - file containing multiple revisions of text, an access
list, a change log, descriptive text, and some control attributes.
-
dbx - utility for source-level debugging and execution of
programs written in Sun C, C++, Fortran, Pascal, Modula-2, and ANSI
C. xdbx is the X Window System interface to the dbx
debugger.
Directories
Commands
Printing