OK, here are some notes I initially prepared to update the wiki but, as usual, never got around to it. For a while I used fpc320 beta / rc1 and the note were not updated, sorry. So, I have hacked away here, IT HAS NOT BEEN TESTED but you can see what we are trying to do, if you get a an error message, I am sure you will be able to adjust it accordingly.
This all assumes you have installed fpc and its source in the locations mentioned in the wiki page, if you have them somewhere else, you will have to adjust. (You will probably need to adjust for my mistakes anyway !)
Installing Lazarus Cross Compiler
Mis named actually, Lazarus does not need anything done to cross-compile, everything you do is done to FPC and its friends. But do build Lazarus, one way or another, from source, you need it in user space.
Install FPC from a tarball, I will then build the Lazarus IDE from source so all lazarus files end up in my home directory and I don't need to mess with permissions to to change them. The alt is to use the sourceforge lazarus deb but I found that a bit constricting.
Setup Linux i386 compiler and Windows compilers
These are the dependencies for the i386 linux compiler.
apt install libc6-dev-i386 libx11-6:i386 libx11-dev:i386 libgdk-pixbuf2.0-0:i386 libatk1.0-dev:i386 libgdk-pixbuf2.0-dev:i386 libpango1.0-dev:i386 libgtk2.0-dev:i386 libnotify-dev:i386
we need libc6-dev-i386 (they are just little bash scripts that call ld and as with specific options), see if you have them already -
which i386-linux-ld
which i386-linux-as
If not, they could be installed under /usr but probably makes sense to do so in the same place we put FPC binaries, a place we will add to path, $HOME/bin/FPC/fpc-3.2.0/bin
cat > $HOME/bin/FPC/fpc-3.2.0/bin/i386-linux-ld
!#/bin/bash
ld -A elf32-i386 $@
cat > $HOME/bin/FPC/fpc-3.2.0/bin/i386-linux-as
#!/bin/bash
as --32 $@
chmod +x $HOME/bin/FPC/fpc-3.2.0/bin/i386-linux-ld
chmod +x $HOME/bin/FPC/fpc-3.2.0/bin/i386-linux-as
# Setup i386 underlying stuff
cd $HOME/bin/FPC/SRC/3.2.0/
make all CPU_TARGET=i386
make crossinstall CPU_TARGET=i386 INSTALL_PREFIX=/home/bin/dbannon/FPC/fpc-3.2.0
# Setup 32bit and 64 bit Windows
cd $HOME/bin/FPC/SRC/3.2.0
make clean all OS_TARGET=win32 CPU_TARGET=i386
make crossinstall OS_TARGET=win32 CPU_TARGET=i386 INSTALL_PREFIX=$HOME/bin/FPC/fpc-3.2.0/bin/
OK, we now have a working cross compiler, lets build the libraries
make clean all OS_TARGET=win64 CPU_TARGET=x86_64
make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=$HOME/bin/FPC/fpc-3.2.0/bin/
// ln -sf /usr/lib/fpc/$FPCVER/ppcrossx64 /usr/bin/ppcrossx64 // ignore, I think....
# Make sure its all there (we should see ppcross386, ppcrossx64)
which ppcrossx64
which ppcross386
Notes -
All this might be nonsense, I have not proof read it !
To install the necessary 32 bit libraries, we need to add :i386 to package name
Issues with Linux32
Try a compile, its quite likely that the two windows modes will work fine but the Linux32 will fail at the linking stage, you must solve missing libraries and/or object files. And its a mess ! Multiarch Ubuntu can transparently support both 32bit and 64bit code but there seems there is no agreement about where the necessary extra files live. So, lets deal with the packages first. Lazarus will tell you what its missing in its messages window. Your problem may be that the 32bit library is not installed, it may be installed somewhere where Lazarus is not looking or it maybe that the name Lazarus is checking for does not exist but the library is there all along.
So, a good start is to search for the name as mentioned in the lazarus error message, lets say the message mentions "-lX11" (meaning the linked was passed X11 as a parameter to -l) -
find /usr -name "libX11*" <enter>
/usr/lib/i386-linux-gnu/libX11.so.6.3.0
/usr/lib/i386-linux-gnu/libX11.so.6
/usr/lib/x86_64-linux-gnu/libX11.so
/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
/usr/lib/x86_64-linux-gnu/libX11.so.6
Here (a few lines removed for clarity) we have two real libraries, one in gnu 32bit and one in the gnu 64bit directory. The remainders are symlinks (go ahead, try ls -l on them). But while there is a symlink called libX11.so in the 64bit dir, there is not one in the 32bit dir. And that is what Lazarus is looking for.
ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so <enter>
If there is no 32bit version showing up, install it -
sudo apt install libX11:i386 <enter>
Note the ':i386', thats how we tell it to get the 32bit version.
And, the third possibility, its there all along but Lazarus cannot see it, .....
NOTE: at this stage, I initially played with fpc.cfg, however, that now seems unnecessary, maybe it was a one off while generating the cross compiler ?? Anyway, in this block
# path to the gcclib,
#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-linux-gnu/9/32
#endif
I had added -Fl/usr/lib32 and -FL/usr/lib/i386-linux-gnu confirm later .....
just why this is necessary, I don't know, should Lazarus be searching for the various combinations or should Ubuntu install all possible links ? In /usr/lib/x86_64-linux-gnu/libX11 for example, we have all possible links....
If you see messages about crtn.o (or crti.0) failure at linking stage, first check where your 32bit versions of these files are.
find /usr -name crtn.o <enter>
They may well be in /usr/lib32 but apparently pointing a -Fl at them does not help (it seems other things, maybe ld itself, does really wants them in the gcc dir). Best thing to do is add a sym link from each to the gcc directory, its already mentioned in fpc.cfg. In my case, the gcc release is '9', your may well be anything from 7 to infinity. Use the one mentioned in your fpc.cfg file, fpcmakcfg knows what its doing.
ln -s /usr/lib32/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/32/crti.o
ln -s /usr/lib32/crtn.o /usr/lib/gcc/x86_64-linux-gnu/9/32/crtn.o