A cross compiler works on a specific operating system (the host) and
compiles/links code for another processor/operating system (the target)
I think one needs the following things to build a free pascal
1. A cross compiler which can be executed/run on the host computer and
compiles to the target computer. (as.exe will be the cross compiler )
2. A cross linker which can be executed/run on the host computer and links
to the target computer.
( ls.exe will be the cross linker )
3. Free Pascal Compiled Units for the target computer.
( c:/pp/units/linux )
( I don't know how to compile these units for the target computer, I
downloaded them from somebody else )
Here are some steps/tips to help you
I build a free pascal cross compiler once.
It compiles from win32 to linux.
Here some tips:
1. Install Free Pascal ( Binary )
2. Install CygWin ( Binary ) Download all developer things.
3. Install BinUtils-2.14 (or maybe another version) ( Source )
4. Find somebody with compiled free pascal linux units. Place them in
5. Go in CygWin
6. Type: which make
7. Check if it's cygwin's make. If it's the wrong version than alter
cygwin.bat and change the path so that only windows folders and this path is
in it: c:\cygwin\bin
8. Go to the binutils folder
To list folders and files type: ls
To go to root type: cd c:/
To go to binutils type: cd /binutils-2.14
Make a new build folder by typing: mkdir build
Type: cd build
Type: ../configure --target=i686-linux
This means it executes the program in the parent folder and places the
output in the current folder which should be c:/binutils-2.14/build
This configure program will make a new make file so that the binutils can be
compiled for linux
BinUtils contains a as.exe ( cross assembler ) and a ld.exe ( cross
linker ) you need these two for the cross compiler.
9. Disable firewalls and virus scanners, plug the network cables.
10. Type: make
It will take very long to make the new as-new.exe and ld-new.exe
11. After it's done you have two new files:
as-new.exe is located in build\as\
ld-new.exe is located in build\ld\
Execute as-new.exe with the parameter -v
This parameter will show you if the target is indeed linux.
If you get errors will doing this you are using the wrong cygwin1.dll. There
could be multiple copies of
cygwin1.dll on your system.
The solution is to copy the cygwin1.dll file from c:\cygwin\bin to the
13. Copy as-new.exe to c:\pp\bin\linux and rename it to as.exe
14. Copy ld-new.exe to c:\pp\bin\linux and rename it to ld.exe
15. Change the windows path variable so that c:\cygwin\bin is removed from
If you don't do this then free pascal cross compiler might use the wrong
as.exe and ld.exe.
16. Make a simply hello world example and compile it like this:
fpc -TLINUX hello.pas
The result will be a linux executable without an extension.
Go to linux and type:
To run it.
If you uploaded it to a linux machine via ftp or something and you are using
ssh/putty whatever you might first need to give it execute permissions etc.