96Chapter3 • Compilers and Assemblers
[rr@conformix 4]$ fpc hello.pas
Free Pascal Compiler version 1.0.4 [2000/12/18] for i386
Copyright (c) 1993-2000 by Florian Klaempfl
Target OS: Linux for i386
Compiling hello.pas
Assembling hello
Linking hello
6 Lines compiled, 0.1 sec
[rr@conformix 4]$
The output
hello
program can be executed like any other program.
3.10.2Using GNU Pascal
A GNU Pascal compiler is available from http://agnes.dida.physik.uni-essen.de/~gnu-pas-
cal/ for download and can be installed on many platforms like
gcc
. The web site contains all
manuals and downloadable files for this compiler. This compiler also creates executable files
from Pascal source code.
3.11Compiling Fortran Programs
The GCC family of compilers also includes
g77
which acts as a front end to invoke
gcc
. The
gcc
compiler is used to compile Fortran programs. Consider the following simple
hello.for
Fortran program that write “Hello world” on standard output.
c This program is to display a string and then end
c Written to demonstrate Fortran program compilation
c
c Rafeeq Rehman, March 18, 2002
program hello
write (*,*) 'Hello world'
stop
end
Note that statements in Fortran start from column 7. All lines starting with c in column 1
are comment lines. You can compile this program using the following command:
g77 hello.for
The
g77
compiler, like
gcc,
creates
a.out
as a default output executable. You can cre-
ate output file with a different name using –
o
command line option. The following command
creates “kaka” as output binary executable file.
g77 hello.for –o kaka
The
g77
program uses many programs to generate output binary. You can display version
information by using
g77 –v
command. Output of this command is shown below.
Next Page >>
<< Previous Page
Back to the Table of Contents