Sign in Join

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

Mailing lists / fpc-pascal / 2012-04

cross compiling - easier than expected - wiki needs update?

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Bernd

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

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

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.

Bernd

Reply by email

Mattias Gaertner
to Bernd
Show quoted text 37 lines
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?

Show quoted text 11 lines
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!

:)

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

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

Reply by email

Bernd
to Mattias Gaertner

2012/4/29 Mattias Gaertner :

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

I tried this but then it seems it would try to use what is configured in "Build Lazarus" which is set to GTK2 on my machine. When I try to run the resulting exe in wine then it will print this error and exit:

err:module:import_dll Library libgdk-win32-2.0-0.dll (which is needed by L"Z:\\home\\bernd\\proj\\inventar\\inventar.exe") not found

Reply by email

Marco van de Voort
to Bernd: I just thought I kill some time investigating cross compiling from i386-linux to…

In our previous episode, Bernd said:

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

A small warning, and possibly another outdated point, but afaik this might go wrong if starting FPC version built FPC version.

Check make install output to see what "fpc"/"ppc386" binaries are used for the process (since the version number of the destination depends on it)

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

That shouldn't be necessary as Mattias already pointed out.

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

Non windows as target brings in binutils. For windows they are built in.

Reply by email

Mattias Gaertner
to Bernd: 2012/4/29 Mattias Gaertner : I tried this but then it seems it would try to use what is…
Show quoted text 11 lines
2012/4/29 Mattias Gaertner : > You don't need to set the LCLWidgetType here because win32 is the > default for TargetOS win32. I tried this but then it seems it would try to use what is configured in "Build Lazarus" which is set to GTK2 on my machine. When I try to run the resulting exe in wine then it will print this error and exit: err:module:import_dll Library libgdk-win32-2.0-0.dll (which is needed by L"Z:\\home\\bernd\\proj\\inventar\\inventar.exe") not found

I fixed that. Please test.

Mattias

Reply by email

Bernd
to Mattias Gaertner

2012/4/29 Mattias Gaertner :

> I tried this but then it seems it would try to use what is configured > in "Build Lazarus" I fixed that. Please test.

Now it works, now just setting the target OS is sufficient :-) Thank you!

Bernd

Reply by email