01.09.2014 Views

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CH03.fm Page 95 Monday, October 7, 2002 8:33 PM<br />

Compiling Pascal Programs 95<br />

<strong>The</strong> output hello.c file is shown below:<br />

/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C<br />

translator */<br />

/* From input file "hello.pas" */<br />

/* Program to demonstrate Pascal compilation */<br />

#include <br />

main(argc, argv)<br />

int argc;<br />

Char *argv[];<br />

{<br />

PASCAL_MAIN(argc, argv);<br />

printf("Hello world\n");<br />

exit(EXIT_SUCCESS);<br />

}<br />

/* End. */<br />

You may need some libraries with p2c program <strong>and</strong> C compiler to successfully complete<br />

this process.<br />

Many Pascal compilers are also available in the open source world. <strong>The</strong>se compilers can<br />

be used to generate executable code from Pascal source directly without any help from GCC.<br />

3.10.1 <strong>Using</strong> Free Pascal (fpc)<br />

<strong>The</strong> Free Pascal Project has created a 32-bit Pascal compiler which is available for <strong>Linux</strong>,<br />

among other operating systems. You can download it from http://www.freepascal.org. This software<br />

is licensed under GPL like other open source projects. At the time of writing this book version<br />

1.0.4 is available for download. After download, you can install the compiler as follows on<br />

a RedHat system:<br />

[root@conformix rr]# rpm --install fpc-1.0.4.i386.rpm<br />

Write permission in /etc.<br />

Found libgcc.a in /usr/lib/gcc-lib/i386-redhat-linux/2.96<br />

Writing sample configuration file to /etc/ppc386.cfg<br />

[root@conformix rr]#<br />

<strong>The</strong> best thing about this compiler is that you don’t need to convert source code files to C<br />

language <strong>and</strong> then compile these. <strong>The</strong> fpc compiler creates binary executable files. <strong>The</strong> following<br />

comm<strong>and</strong> creates an executable file hello from hello.pas program listed earlier.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!