Warning: This site is under construction, most links will be broken.
How to: Using the 32-bit freepascal compiler on 64-bit linux
Last modified on Tue, 16th Feb 2010 at 22:05 GMT by zippletI wrote this guide as I recently switched my home linux box to a 64-bit version of ubuntu server and had problems compiling 32-bit binaries from freepascal.
1. Obtain and install the 32-bit version of freepascal
This is the easy bit. You want the 32-bit linux binary release in a tar archive - http://www.freepascal.org/down/i386/linux.var. As root, extract this tarball and start the installation:
wget <filename>
tar -xvf <filename>
./install.sh
Accept all of the defaults (just hit enter). Freepascal is now installed but currently is useless!
2. Install required packages
/!\ This will differ for other distributions! The instructions here are for debian based distributions. /!\
You need to install the barebones build tools first, if you haven't already:
sudo apt-get install build-essentials
Now install 32-bit specific libraries and build tools:
sudo apt-get install libc6-dev-i386 ia32-libs
3. Configure ld so it knows about the 32-bit libs
We now need to tell ld about the new libraries. For ubuntu server we need to create a new file under /etc/ld.so.conf.d/ containing a path to the 32-bit libs.
Create a file called /etc/ld.so.conf.d/lib32.conf and make sure it contains:
/usr/lib32
Run sudo ldconfig to update the configuration.
4. Configure freepascal
Lastly we need to make some changes to the freepascal configuration file. This usually lives in /etc/fpc.cfg. Open the file in your favourite editor and look for something similiar to this:
# searchpath for libraries
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.1
#endif
#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.1
#endif
We need to alter the library paths and add an extra switch -Xd. Modify it to look like this:
# searchpath for libraries
#ifdef cpux86_64
#-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.1
-Fl/usr/lib32
#endif
#ifdef cpui386
#-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.1
-Fl/usr/lib32
#endif
# Extra switch
-Xd
It is good practice to leave the default there, commented out.