Sunday, July 18, 2010

 

Installing FreePascal 2.5.1 on FreeBsd 8.x-i386


The other day my Ubuntu 9.10 home server broke my /boot partition and Grub2 wasn't able to boot, I don't know why this happened, I tried to reinstall Grub2 using SystemRescueCD and lost one complete day trying, but it didn't work, so I thaught it whould be the time to try FreeBSD 8.1-RC2.

This server's purpouse is mainly to act as a file server, it also has MySql and Firebird installed for my Delphi/FPC applications, Apache for testing my customer's web sites before deploying, and SVN.

After installing the basics (Apache, database servers, SVN, SSH, VIM, etc.) I allways install FPC to compile my CGI apps inside the server. I'm sure I'm not the only one who needs to compile FPC from scratch, therefore, here is my step by step guide.

The server is and AMD64, but as I didn't find an FPC 2.4.0 executable for FreeBSD x86_64 I had to settle on the i386 version for now :(.

This guide assumes you are in /home/USER/dev, where USER is YOU!, in my case, USER=leonardo, so let's position in that place:
cd /home/leonardo/dev

Before you can compile the compiler code, you'll need an executable FPC for your platform, this process is called bootstrapping, in my case I needed a 2.4.1 compiler for FreeBsd i386, so I downloaded it from sourceforge using this command:
wget http://downloads.sourceforge.net/project/freepascal/Bootstrap/2.4.0/ppc386-freebsd-7.bz2

After donwloading it, I had to uncompress (it's bzipped), change its name to ppc386 and changed it mode to executable:
bzip2 -d ppc386-freebsd-7.bz2
mv ppc386-freebsd-7 ppc386
chmod +x ppc386

If you don't have subversion installed you'll have to install it with this command:
sudo pkg_add -r subversion

Now get the source code of FPC, in this case, the trunk version (2.5.1) in the "fpc" directory.
svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc

One difference between FreeBSD and Linux version of FPC is that you have to use "gmake" instead of "make" to build the compiler, that's because FreeBSD's make isn't GNU Make as in Linux. Ok, just use gmake and you'll be ok:
gmake all PP=/home/leonardo/dev/ppc386
sudo gmake install PP=/home/leonardo/dev/ppc386

After gmake install, the compiler files are in /usr/local/lib/fpc/2.5.1, then you have to move to that directory to create an fpc.cfg:
cd /usr/local/lib/fpc/2.5.1/
sudo ./samplecfg /usr/local/lib/fpc/2.5.1 /usr/local/etc

That's it, now you can create modern Object Pascal programs on FreeBSD!.

P.S.: From Jul 24 up to Aug 13 I'll be in Europe!, in France, Italy and Spain. If you want to meet me to chat about Delphi/FPC, please drop me an email to arrange the meeting.
Comments:
Great job!
Today I just use Windows to test CGI made with FPC. In the future, I will need to install FPC in UNIX systems and post like that is very important. Thanks!

We see on the official list :)

MD
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?