Author Topic: Cross-compile  (Read 9987 times)


  • Hero Member
  • *****
  • Posts: 8243
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Cross-compile
« Reply #15 on: August 26, 2014, 08:51:26 am »
Any suggestions on fixing the forced FPC option
No idea, I never require that when I have fpc in PATH. You can check the Makefile yourself, how it looks for FPC.
and the errors on the end?
Have the required libs.


  • New Member
  • *
  • Posts: 34
Re: Cross-compile
« Reply #16 on: August 26, 2014, 12:27:55 pm »
I have them for x86_64 as otherwise the basic project wouldn't compile.
How to get them for any architecture?


  • New Member
  • *
  • Posts: 34
Re: Cross-compile
« Reply #17 on: August 26, 2014, 11:12:03 pm »
My approach installed on a VM:
Ubuntu 14.04LTS 64bit
Updated by using
Code: [Select]
sudo apt-get update && sudo apt-get upgradeInstalled several useful tools:
Code: [Select]
sudo apt-get install vim build-essentials dkms linux-headers-generic
After this, my OS was setup successfully.

Next was to install FPC and Lazarus.
Doing this by installing it from source instead of using the ubuntu repo's
Downloaded FPC here: -> fpc-2.6.4.x86_64-linux.tar

Downloaded sources of FPC here: -> fpc-2.6.4.source.tar.gz

Downloaded Lazarus here: -> lazarus-1.2.4-0.tar.gz

1. First installed fpc by untarring and running the install script
Code: [Select]
sh install.shThe PREFIX I used is: /home/<username>/fpc
I installed everything (default Y)
2. Second I untarred the sources of fpc into a directory ~/fpcsrc
3. Last part of this is installing lazarus. Did this by untarring it to ~/lazarus
Running make all inside this folder didn't work out because the fpc compiler could not be found. This because the system does not know where to find the fpc. To fix this temporarily, I added the location to it by hand:
Code: [Select]
PATH=$PATH:/home/<username>/fpc/bin and ran the command again (make all).
At the end, I was missing some libraries. Using this wiki, i had to use following commands:
Code: [Select]
sudo apt-get install libgtk2.0-dev
sudo apt-get install libgdk-pixbuf-dev
and than run
Code: [Select]
make clean all
Lazarus was now compiled and ready to use. To make it able to compile the basic project, open up lazarus (./lazarus in the ~/lazarus directory) and set the correct paths for fpc (~/fpc) and fpcsrc (~/fpcsrc). That should do the trick.

My first goal was to compile an 32bit program so I followed this guide hoping to get this working.
I did not have the 2 files, so I created them and ran the commands as described.

At the end of this compilation, I receive several errors of missing libraries:
Code: [Select]
ld: warning: ./link.res contains output sections; did you forget -T?
ld: cannot find -lpthread
ld: cannot find -ldl
ld: cannot find -lc
fppkg.pp(396,1) Error: Error while linking
fppkg.pp(396,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
I guess this is due the fact that my system does not have the required binutils? Is this correct? Or is this just because some path is not set correctly? If this is because of missing binutils, how to get those libraries?

==> The missing libraries are libpthread, libdl and libc. To get more information about them, I installed apt-file (sudo apt-get install apt-file)
Code: [Select]
sudo apt-file search gave several hits. As I am trying to compile for i386, I found out that I had to install libc6-dev-i386.
After this was installed, I ran the command again (make clean all CPU_TARGET=i386) and the compilation went fine!

The next step is to crossinstall it and running does not work when the correct paths aren't setup. To fix this, edit the /etc/environment file and add this at the end of the file:
:/home/<username>/fpc/bin" (keep in mind this is before the " !!)
Log out and back in for the changes to take effect. You should be able to run the sudo make crossinstall CPU_TARGET=i386 command without an issue.

Right now, should I copy the 32bit compiler to somewhere else or can I leave it in there? If I make a new compiler, will I lose this one? Also, I have to edit the fpc.cfg file but where to target it to? /home/<username>/fpcsrc?

This didn't add any new directory to the /home/<username>/fpc/lib/fpc/2.6.4/units/ folder. So using the BuildFAQ, I used following command:
Code: [Select]
make all crossinstall CPU_TARGET=i386 INSTALL_PREFIX=/home/<username>/fpcNow, an additional folder is created in the units folder. Right now it contains x86_64-linux and i386-linux folders. That seems right to me. However, when running Lazarus and picking the CPU=i386 option in the Project Options panel, Lazarus complains the compiler does not support i386 target.

This is because the crossinstall didn't setup the correct symbolic links. To do so, you should make a symbolic link to the ppc386 located in /home/<username>/fpc EDIT: will complete later-on
« Last Edit: August 28, 2014, 08:56:26 pm by BlueMoony »


TinyPortal © 2005-2018