Sign in Join

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

Mailing lists / lazarus / 2016-07

Unable to cross-compile Lazarus applications in Linux from x86_64 to arm target (Raspberry pi 3)

17 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Giuliano Colla

Hi all,

I'm trying to set up my Lazarus in a Linux x86_64 platform to cross compile for an ARMV7 target (Raspberry pi 3), but I'm unable to make it work.

The environment is CentOs 6, Linux x86_64, fpc 2.6.4. Both Lazarus 1.4.4 and Lazarus 1.7 (from trunk) give identical results. The target should be arm-linux.

I believe that my custom fpc.cfg is properly set, because I can cross-compile a simple console app:

fpc -Tlinux -Parm -XParm-linux- TestArm.pas

works just fine and generates an arm object file and an arm executable, which runs on the target.

But up to now, any attempt to cross-compile on Lazarus has failed.

I assume that I should set Target OS = Linux, Target CPU family = arm, Target processor = ARMV7

But with those parameters the compilation aborts immediately with "Illegal parameter -CpARMV7"

If I set Target processor = Default, I must add a lot of extra paths to make it find the sources (why?), but finally it compiles everything, and properly puts the generated .o and .ppu files in the arm-linux directories. But the generated .o files are of type ELF x86-64, and then ld aborts, telling (correctly) that it supports only the arm formats.

With this setup the compiler options are:

Show quoted text 13 lines
-Tlinux -Parm -MObjFPC -Scghi -O1 -g -gl -l -vewnhibq -Filib/arm-linux -Fi/usr/lib64/lazarus/lcl/include -Fu../fpc/2.6.4/packages/fcl-process/src -Fu/usr/lib64/lazarus/components/lazutils -Fu/usr/lib64/lazarus/lcl -Fu/usr/lib64/lazarus/lcl/widgetset -Fu/usr/lib64/lazarus/lcl/interfaces/gtk2 -Fu../lazarus/lcl/units/arm-linux/gtk2 -Fu../lazarus/lcl/units/arm-linux -Fu../lazarus/components/lazutils/lib/arm-linux -Fu../lazarus/packager/units/arm-linux -Fu. -FUlib/arm-linux -dLCL -dLCLgtk2 -XParm-linux-

What I'm doing wrong? What I'm missing?

Any help is greatly appreciated.

Thanks in advance,

Giuliano

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160711/a296805d/attachment.html>

Reply by email

leledumbo
to Giuliano Colla
What I'm doing wrong?

That one: "I must add a lot of extra paths to make it find the sources " NEVER EVER add path to package sources directly.

What I'm missing?

Check whether your compiler path calls fpc driver instead of ppcx64 or some other real ppcXXX compiler. Examine the messages window, compile with -va if required, then check the early messages.

Reply by email

Mattias Gaertner
to fred
Show quoted text 6 lines
hy, when y launch a program who compiled with lazarus with a link on the desktop the program create a file named gnom.out What's this ?

The gnu profiler log. It is created when the program is compiled with -pg.

Mattias

Reply by email

fred
to Mattias Gaertner

where is this option on the lazarus ide ?

They are a lot of components configure for lazarus so i use lazarus version of codetyphon.

Friendly
Frédéric

Mattias Gaertner wrote 14 lines
On Mon, 11 Jul 2016 21:14:48 +0200 fred wrote: > hy, > > when y launch a program who compiled with lazarus > with a link on the desktop the program create a file named gnom.out > > What's this ? The gnu profiler log. It is created when the program is compiled with -pg. Mattias

Reply by email

Mattias Gaertner
to fred
where is this option on the lazarus ide ? They are a lot of components configure for lazarus so i use lazarus version of codetyphon.

The standard Lazarus project options has a search. Typing 'pg' shows Compiler Options / Debugging / generate code for gprof.

Mattias

Reply by email

fred
to fred

hy,

With a tutorial i make an install of lazarus and fpc to haiku project (beos)

the interface is qt4.5.3

Can i install and compile lazarus and fpc to haiku (last version) ?

Friendly
Frédéric

Reply by email

Giuliano Colla
to leledumbo: That one: "I must add a lot of extra paths to make it find the sources " NEVER EVER add…

Il 11/07/2016 20:01, leledumbo ha scritto:

Check whether your compiler path calls fpc driver instead of ppcx64 or some other real ppcXXX compiler. Examine the messages window, compile with -va if required, then check the early messages.

I did clean up everything and restarted fresh. But still it doesn't work.

Compiler messages are:

Free Pascal Compiler version 2.6.4 [2016/07/12] for arm Copyright (c) 1993-2014 by Florian Klaempfl and others (1002) Target OS: Linux for ARMEL
(3104) Compiling fcllaz.pas
(3104) Compiling registerfcl.pas
(3104) Compiling lazaruspackageintf.pas
(9009) Assembling lazaruspackageintf
lazaruspackageintf.pas(104) Error: (9005) Assembler /home/colla/Applicazioni/lazarus/fpc/binutils/as not found, switching to external assembling lazaruspackageintf.pas(104) Fatal: (10026) There were 1 errors compiling module, stopping Fatal: (1018) Compilation aborted
Error: /usr/local/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)

but if I go to the folder of lazaruspackageintf.pas/units/arm-linux I find an assembler file lazaruspackageintf.s, and if I launch manually the Assembler "not found", it assembles the file properly and generates an a.out relocatable ARM object file.

Any idea?

Giuliano

Reply by email

Mattias Gaertner
to Giuliano Colla
Show quoted text 6 lines
Il 11/07/2016 20:01, leledumbo ha scritto: > Check whether your compiler path calls fpc driver instead of ppcx64 or some > other real ppcXXX compiler. Examine the messages window, compile with -va if > required, then check the early messages. I did clean up everything and restarted fresh. But still it doesn't work.

What compiler is now called?

Show quoted text 18 lines
Compiler messages are: Free Pascal Compiler version 2.6.4 [2016/07/12] for arm Copyright (c) 1993-2014 by Florian Klaempfl and others (1002) Target OS: Linux for ARMEL (3104) Compiling fcllaz.pas (3104) Compiling registerfcl.pas (3104) Compiling lazaruspackageintf.pas (9009) Assembling lazaruspackageintf lazaruspackageintf.pas(104) Error: (9005) Assembler /home/colla/Applicazioni/lazarus/fpc/binutils/as not found, switching to external assembling lazaruspackageintf.pas(104) Fatal: (10026) There were 1 errors compiling module, stopping Fatal: (1018) Compilation aborted Error: /usr/local/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled) but if I go to the folder of lazaruspackageintf.pas/units/arm-linux I find an assembler file lazaruspackageintf.s, and if I launch manually the Assembler "not found", it assembles the file properly and generates an a.out relocatable ARM object file.

Why does FPC say
Assembler /home/colla/Applicazioni/lazarus/fpc/binutils/as not found?

Mattias

Reply by email

Giuliano Colla
to Mattias Gaertner

An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160713/9f26f982/attachment-0001.html> -------------- next part --------------
SetPrimaryConfigPath NewValue="~/.lazarus_svn/" -> "/home/colla/.lazarus_svn/" Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] PrimaryConfigPath="/home/colla/.lazarus_svn" Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] SecondaryConfigPath="/etc/lazarus" Hint: (lazarus) [TBuildManager.SetBuildTarget] Old=x86_64-linux-qt New=x86_64-linux-qt FPC=True LCL=False Warning: (lazarus) Macro not defined: "Target_OS". TComponentTreeView.RebuildComponentNodes: Updating TreeView with components TComponentTreeView.SetSelection: Updating component node values. Warning: (lazarus) Macro not defined: "Target_OS". Hint: (lazarus) [TBuildManager.SetBuildTarget] Old=x86_64-linux-qt New=arm-linux-gtk2 FPC=True LCL=True Warning: (lazarus) Macro not defined: "Target_OS". TLazSourceFileManager.InitOpenedProjectFile select form in designer: Form1:TForm1 TDesigner TComponentTreeView.RebuildComponentNodes: Updating TreeView with components Warning: (lazarus) Macro not defined: "Target_OS". Hint: (lazarus) Last compile was incomplete for FCL 1.0.1 State file="/home/colla/Applicazioni/lazarus/packager/units/arm-linux/FCL.compiled" Hint: (lazarus) Missing state file of LazUtils 1.0: /home/colla/Applicazioni/lazarus/components/lazutils/lib/arm-linux/LazUtils.compiled Hint: (lazarus) Missing state file of LCLBase 1.7: /home/colla/Applicazioni/lazarus/lcl/units/arm-linux/LCLBase.compiled Hint: (lazarus) Missing state file of LCL 1.7: /home/colla/Applicazioni/lazarus/lcl/units/arm-linux/gtk2/LCL.compiled Info: (lazarus) Execute Title="Compile package FCL 1.0.1" Info: (lazarus) Working Directory="/home/colla/Applicazioni/lazarus/packager/registration/" Info: (lazarus) Executable="/usr/bin/fpc"
Info: (lazarus) Param[0]="-Parm"
Info: (lazarus) Param[1]="-MObjFPC"
Info: (lazarus) Param[2]="-Scghi"
Info: (lazarus) Param[3]="-O1"
Info: (lazarus) Param[4]="-g"
Info: (lazarus) Param[5]="-gl"
Info: (lazarus) Param[6]="-l"
Info: (lazarus) Param[7]="-vewnhibq"
Info: (lazarus) Param[8]="-Fu/home/colla/Applicazioni/lazarus/packager/registration/" Info: (lazarus) Param[9]="-FU/home/colla/Applicazioni/lazarus/packager/units/arm-linux/" Info: (lazarus) Param[10]="fcllaz.pas"
Error: (lazarus) [TLazPackageGraph.CompileRequiredPackages] "Codice di uscita 1" Error: (lazarus) [TMainIDE.DoBuildProject] PkgBoss.DoCompileProjectDependencies failed TComponentTreeView.RebuildComponentNodes: Updating TreeView with components LAZARUS END - cleaning up ...
Hint: (lazarus) [TMainIDE.Destroy] B -> inherited Destroy... TMainIDE Hint: (lazaAdding "--pcp=~/.lazarus_svn/" as a parameter project1.lpi is a file
is a file
SetPrimaryConfigPath NewValue="~/.lazarus_svn/" -> "/home/colla/.lazarus_svn/" TLazarusManager.Run starting /home/colla/Applicazioni/lazarus/lazarus ...

Reply by email

Giuliano Colla
to Mattias Gaertner: On Tue, 12 Jul 2016 19:21:36 +0200 What compiler is now called? Why does FPC say…

Il 13/07/2016 14:06, Mattias Gaertner ha scritto:

Why does FPC say Assembler /home/colla/Applicazioni/lazarus/fpc/binutils/as not found?

Because I had added one of the required options, i.e. -XParm-linux- in Custom Options (which applies only to project files) and not in Additions and Overrides, which applies also to packages.

Now everything complies properly, and it fails only when the loader attempts to load the cross libraries which I have not yet installed in the proper location, because I counted on the loader error messages to install just what's needed.

As soon as I have some time to spare, I'll update the wiki page, which still reflects what was done before LCL was recompiled automatically when needed.

Thanks to everybody,

Giuliano

Reply by email

Mattias Gaertner
to Giuliano Colla: An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/at…
Show quoted text 8 lines
Il 13/07/2016 14:06, Mattias Gaertner ha scritto: [...] fpc->ppcarm 2.6.4 [...] Assembler /home/colla/Applicazioni/lazarus/fpc/binutils/as not found? [...] Copying and pasting all the compiler options from Lazarus "View options" again works just fine: fpc  -Tlinux -Parm -CpARMV7 -MObjFPC -Scghi -O1 -g -gl -Xg  -k-L/home/colla/Applicazioni/lazarus/fpc/libcross -l -vabq -Fi/home/colla/Applicazioni/Raspberry/Cross/lib/arm-linux -Fu/home/colla/Applicazioni/lazarus/lcl/units/arm-linux/gtk2 -Fu/home/colla/Applicazioni/lazarus/lcl/units/arm-linux -Fu/home/colla/Applicazioni/lazarus/components/lazutils/lib/arm-linux -Fu/home/colla/Applicazioni/lazarus/packager/units/arm-linux -Fu/home/colla/Applicazioni/Raspberry/Cross/ -FU/home/colla/Applicazioni/Raspberry/Cross/lib/arm-linux/ -dLCL -dLCLgtk2 -XParm-linux- fcllaz.pas >out3.txt When the compile or build is launched from within Lazarus (1.4.4 and 1.7 behave the same), it fails with "Assembler not found".

Check that the IDE uses the same PATH variable as your terminal. Instead of "fpc" try using "ppcarm" with full path in the IDE. Instead of "View Options", right click in Messages window on the red header line / About. This gives you the actual parameters of the TProcess instance.

If I move in the proper place .o's and .ppu's obtained with manual compilation I can proceed one step further, but next compilation fails for the same reason.

Also make sure you have enough memory. Compiling in the IDE needs more memory.

My wild guess has been that Lazarus doesn't pass all the required options to the compiler, or maybe not in the proper order. Unfortunately, even setting -va, when compiling from lazarus the resulting messages (even Save All) are much more concise than the raw compiler output, and it's rather hard to understand what goes wrong.

Probably stdout vs stderr.

I resorted to launching lazarus from command line and redirecting the output to a file. One can see something but is it the full story? I enclose the lazout.txt file where it would appear that the options passed to FPC aren't as complete as desirable (-CpARMV7 has disappeared, and so -XParm-linux- which are both required by FPC). Is that the reason?

I'm not an arm expert.

Mattias

Reply by email

Giuliano Colla
to Mattias Gaertner

Il 14/07/2016 00:37, Mattias Gaertner ha scritto:

I'm not an arm expert.

I'm not either. But I'm forced by circumstances to learn :'(. The Raspberry Pi3 is quite popular and has enough computing power to be usable in our field of industrial applications.

Maybe you missed my previous post. The compile problem is solved. I had set one of the required options in Custom Options (which applies only to project files) instead of putting it in Additions and Overrides (which applies also to packages). That way it compiles properly both the LCL and the project, it links with the appropriate cross-libraries and it generates an arm executable.

However there is still a minor issues, and a major one:

1. When cross compiling, packages do inherit properly from the project the Target OS and Target CPU Family compiler options, but they do not inherit the Target Processor option. Workaround: add it to Additions and Overrides, but it would deserve a fix.
2. Apparently there is some incompatibility between host and target gtk-related libraries, because, while a console application runs just fine, a visual one crashes at startup because "GtkAdjustment has no property named ''". I'll investigate...

However thank for your help.

Giuliano

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160715/edf6824c/attachment.html>

Reply by email

Joost van der Sluis
to Giuliano Colla: Il 13/07/2016 14:06, Mattias Gaertner ha scritto: Because I had added one of the required…

Op 13-07-16 om 19:54 schreef Giuliano Colla:

Show quoted text 7 lines
Il 13/07/2016 14:06, Mattias Gaertner ha scritto: > Why does FPC say > Assembler /home/colla/Applicazioni/lazarus/fpc/binutils/as not found? Because I had added one of the required options, i.e. -XParm-linux- in Custom Options (which applies only to project files) and not in Additions and Overrides, which applies also to packages.

I do not think that this is the right place for this setting. It does work, but I think it belongs to your fpc.cfg. And it should be part of the installation of the fpc cross-compiler.

So there's no need to fiddle with Lazarus' options.

Joost.

Reply by email

Giuliano Colla
to Joost van der Sluis

Il 16/07/2016 11:07, Joost van der Sluis ha scritto:

Show quoted text 5 lines
I do not think that this is the right place for this setting. It does work, but I think it belongs to your fpc.cfg. And it should be part of the installation of the fpc cross-compiler. So there's no need to fiddle with Lazarus' options.

You're right, but I started by following blindly the wiki page instructions, lacking any experience in cross-compiling. Now that I've gained a better experience on how different options play at different times, I may clean up things, and put the proper options in the proper place.
However thank you for your suggestion.

Giuliano

Reply by email