Saturday, 14 April 2007

Free Pascal

For my first thrilling post, I'd like to tell you all about my entire evening trying to install Free Pascal on my laptop which runs Ubuntu Linux (Dapper Drake, no less). Since I'm not a very experienced user (not at all!) I have been mainly fumbling in the dark. However, since I just managed to compile my first pascal program, I thought I'd share those fumblings with you, incase you're interested. So.

I visited this marvellous website, and downloaded the 2.0.4 release for Linux as a .tar file:
So far, so good. I could have had the .deb packages, but they were numerous, and I didn't know what to do with them, or which ones I needed. So, the .tar version it was. I un-tarred it like so:

tar -xvf fpc-2.0.4.i386-linux.tar

And then I ran the shell script to install it thus:

sudo ./

I wrote an incredible program, and named the file "hello.pp" (my first ever pascal program!)

program hello;
writeln ('Hello, world.');

And then I typed...

fpc hello.pp

But! Woe is me! The computer told me:

hello.pp(4,1) Error: Util ld not found, switching to external linking

Which was very rude. However, after much head scratching and manual searching, I found the following enlightenment from the freepascal user manual:

Under UNIX systems (such as LINUX) you need to have the following programs installed :
1. GNU as, the GNU assembler.
2. GNU ld, the GNU linker.
3. Optionally (but highly recommended) : GNU make. For easy recompiling of the compiler and Run-Time Library, this is needed.

Compiling a compiler? I can't cope with this! A bit more detective work lead me to install binutils using the synaptic package manager, which gave me the gnu assembler and linker. Then my program compiled sweetly and ran when I typed:


Great stuff.

No comments: