[fpc-pascal]Cross-Compiling Debian/Linux -> FreeBSD

James Mills prologic at daisy.ods.org
Wed Oct 8 14:15:37 CEST 2003

On Wed, Oct 08, 2003 at 11:02:45AM +0200, Marco van de Voort wrote:
> > Is there an easy way of cross-compiling other than what I"m currently
> > doing (using a shell account), to cross-compile from Debian/Linux to
> > FreeBSD ?
> There are certainly ways, and you are in luck, I just did this last weekend.
> I'm writing an article about it for a German magazine, and am very
> interested how doable it is for a  common user.
> It is not hard. I generated linux and freebsd binaries on windows
> Some questions first:
> - Is your binary pure FPC, or does it link to C? If it links to C libraries
>    it goes out of my area of expertise.
Hrm,, unfortunately, it does use the SQLite library (www.sqlite.org). Is
it possible to link the library in the binary or do something else ?

In any case, if it's not possible at all with your current knowledge,
I'd like to know how it's done anyway for a pure FPC program :)

> - do you use 1.0.x or 1.1.x (I did it with 1.1.x, but 1.0.x is capable of it too)
Free Pascal Compiler version 1.0.10 [2003/08/18] for i386
Copyright (c) 1993-2003 by Florian Klaempfl

> > If there is, I will need a step-by-step instruction, as I've never done
> > it before without the need for a different machine.
> Let's make the shopping list first:
> You'll need 
> - crossbinutils (from ftp see below)
> - a FreeBSD set of units matching the one you already have for linux.
> Retrieving and installation
> ---------------------------
> Crossbinutils linux->about 10 platforms are available from
> ftp://ftp.freepascal.org/fpc/contrib/cross/linux If this package is really
> to large (26M) because you are not on broadband, yell, and I'll isolate the
> FreeBSD ones from this package.
> Besides this, you need two matching FPC versions, one for FreeBSD one for
> Linux. If you use a release, that is simple, just take the the freebsd
> release, more importantly the $PREFIX/lib/fpc/$VERSION/units/freebsd part.
> Put that in your FPC tree. (so in addition to
> $PREFIX/lib/fpc/$VERSION/units/linux you get also units/freebsd)
> (needs some manual extracting, and you don't need the FreeBSD binaries, just
> the compiled units tree)
> Extract the cross libraries in a temp directory 
> and then go to the "bin" directory and get the i686-linux* files.
> Rename them to remove the prefix (so as,ar,ld)
> Put them in a directory (I'll use  /usr/local/cross/freebsd for the
> remainder of this post), and chmod +x them.
> Editing fpc.cfg
> ------------------
> Make sure that all -Fu lines in your fpc.cfg don't specify units/linux/* at
> the end but change them to units/$TARGET/*  
> Put all additional -Fu commands (for own libraries) under #ifdef linux
> Also add a 
> #ifdef freebsd
> -FD/usr/local/cross/freebsd
> #endif
> For more info about this kind of tricks see the buildfaq, which is a good
> thing to read/have anyway if you are going to try crosscompiling.
> http://www.stack.nl/~marcov/buildfaq.pdf
> The crosscompile
> ---------------
> Make sure that all .o, .a and .ppu files are deleted from your build
> directory and all other include and unit paths in your source tree
> Then type
> ppc386 -Tfreebsd <otheroptions> mymainprogram
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

-Zero Defect Software Engineers Group - ZDSEG
-You need only two tools. WD-40 and duct tape.
-If it doesn't move and it should, use WD-40.
-If it moves and shouldn't, use the tape.

More information about the fpc-pascal mailing list