[fpc-pascal] cross compiling - easier than expected - wiki needs update?

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Apr 29 15:17:29 CEST 2012


On Sun, 29 Apr 2012 15:01:12 +0200
Bernd <prof7bit at googlemail.com> wrote:

> Hi,
> 
> I just thought I kill some time investigating cross compiling from
> i386-linux to i386-win32 and hada look at the wiki page
> http://wiki.freepascal.org/Cross_compiling
> 
> It seems there is some important thing missing, right at the beginning
> but I don't know enough about fpcmake to extend the article in a way
> that explains in a short sentence what fpcmake's actually does (and
> how it does this) and what options are of interest.
> 
> Here is what I had installed initially on my Linux-i386 (Xubuntu 11.10)
> 
> an fpc checkout from the 2.6 fixes branch
> a lazarus checkout from the trunk
> 
> For normal compiling (not cross) after updating everything from svn  I
> usually just use
> 
> in the fpc directory
> make clean all
> sudo make install
> 
> (the fpc.cfg is in /etc and I once created it with the tool that comes
> with fpc and never touched it since)
> 
> and in the Lazarus directory
> make clean lazbuild useride
> 
> (without install, just  run Lazarus directly from there)
> 
> ***
> 
> Now I decided to try experimenting with cross compiling to win32,
> something I have never done before and expected to be very difficult
> to set up. The only problem I had was the wiki page does not mention
> with any word that one must first do fpcmake -Ti386-win32

Normally this is not needed because the makefiles are created with
fpcmake -Tall, which creates Makefile for all targets.
Maybe someone forgot this?

 
> Then it was surprisingly easy:
> 
> fpcmake -Ti386-win32
> make all OS_TARGET=win32 CPU_TARGET=i386
> sudo make crossinstall OS_TARGET=win32 CPU_TARGET=i386
> 
> and that was all!
> 
> I have also seen mentioning somewhere the fpc.cfg needs to be edited
> but my fpc.cfg seemed to already contain the correct $fpctarget
> macros. 

Some years ago some installers created fpc.cfg without the macros.
That's why the wiki mentions it. Feel free to add a comment, that
nowadays this is usually already done.


> Also it seems there is absolutely no additional configuration
> in Lazarus needed, it just worked out of the box immediately on the
> first try! 

:)

> All I did was opening a simple project with some database
> stuff for sqlite that already used to compile and run on windows, I
> just opened the project and set in the project settings:
> 
> Code Generation / Target OS: Win32
> Build Modes / Macro values: LCLWidgetType: win32

You don't need to set the LCLWidgetType here because win32 is the
default for TargetOS win32.

 
> And it immediately worked! It automatically re-compiled all needed LCL
> and other packages without changing *any* Lazarus setting at all and
> it created a working LCL windows exe!
> 
> This is great stuff, I am impressed! I initially prepared for many
> frustrating hours experimenting and searching little pieces of
> information from all over the web but instead it just worked
> immediately! The only thing is the wiki page seems slightly outdated
> in a few details regarding Linux->Windows cross compile:
> 
> * missing hint for fpcmake
> * fpc.cfg probably already ok, no editing here anymore
> * no Lazarus config change, no new Lazarus profile, no rebuilding of
> Lazarus anymore
> 
> maybe this also affects the other cross-compile-combinations (which
> are certainly more complicated because of the binutils but maybe also
> became easier), but I don't have enough experience with this to feel
> confident enough to make changes. Someone else with more routine in
> cross compiling should do this.


Mattias



More information about the fpc-pascal mailing list