Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-10

Cross-Compiling Debian/Linux -> FreeBSD

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

James Mills

Hi,

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 ?

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.

cheers
James

- -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.

Reply by email

Marco van de Voort
to James Mills
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.
- 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)

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

Reply by email

James Mills
to Marco van de Voort
Marco van de Voort wrote 14 lines
> 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

Show quoted text 66 lines
> 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 - 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.

Reply by email

Marco van de Voort
to James Mills
Show quoted text 15 lines
On Wed, Oct 08, 2003 at 11:02:45AM +0200, Marco van de Voort wrote: > > 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 ?

I haven't tested, and there is a gotcha that needs manual editing) but the idea would be

- everything the same as earlier.
- put static libraries of any library you
need in a dir, say /usr/cross/freebsdlib (don't forget libc and libgcc)
- compile using

ppc386 -Tfreebsd -Fl/usr/cross/freebsdlib -kfail <other options> <yourfile>

The process will terminate with an linking error

Then
edit ppas.sh to remove the "fail" word
edit link.res and remove all searchdirs except the /usr/cross/freebsdlib one run ./ppas.sh

Copy the generated file to freebsd, say a prayer, and run it.

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 :)

A better word would be that I haven't tested it yet. But I will soon.

Reply by email

Lee, John

Marco, there isn't much documentation for xcomp around... suggest you put the info in this email, and a link http://www.stack.nl/~marcov/buildfaq.pdf or a copy of the document into ftp:\...contrib\cross\ eg in a readme? Regards John
--------------------

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

Reply by email

Marco van de Voort
to Lee, John
Marco, there isn't much documentation for xcomp around... suggest you put the info in this email, and a link http://www.stack.nl/~marcov/buildfaq.pdf or a copy of the document into ftp:\...contrib\cross\ eg in a readme?

Could do that yes. But I have to finish the article first, then I'll do some documenting in buildfaq.pdf.

Michael can then use that and absorb parts of it into the documentation.

Reply by email