Compiling Pascal Programs95
The output
hello.c
file is shown below:
/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C
translator */
/* From input file "hello.pas" */
/* Program to demonstrate Pascal compilation */
#include
main(argc, argv)
int argc;
Char *argv[];
{
PASCAL_MAIN(argc, argv);
printf("Hello world\n");
exit(EXIT_SUCCESS);
}
/* End. */
You may need some libraries with
p2c
program and C compiler to successfully complete
this process.
Many Pascal compilers are also available in the open source world. These compilers can
be used to generate executable code from Pascal source directly without any help from GCC.
3.10.1Using Free Pascal (fpc)
The Free Pascal Project has created a 32-bit Pascal compiler which is available for Linux,
among other operating systems. You can download it from http://www.freepascal.org. This soft-
ware is licensed under GPL like other open source projects. At the time of writing this book ver-
sion 1.0.4 is available for download. After download, you can install the compiler as follows on
a RedHat system:
[root@conformix rr]# rpm --install fpc-1.0.4.i386.rpm
Write permission in /etc.
Found libgcc.a in /usr/lib/gcc-lib/i386-redhat-linux/2.96
Writing sample configuration file to /etc/ppc386.cfg
[root@conformix rr]#
The best thing about this compiler is that you don’t need to convert source code files to C
language and then compile these. The fpc compiler creates binary executable files. The follow-
ing command creates an executable file
hello
from
hello.pas
program listed earlier.
Next Page >>
<< Previous Page
Back to the Table of Contents