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

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

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

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:

-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



--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

leledumbo
Administrator
> 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 | Threaded
Open this post in threaded view
|

[Lazarus] Lazarus - fpc 3

Craps
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 ?

Thank's


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Lazarus - fpc 3

Mattias Gaertner
On Mon, 11 Jul 2016 21:14:48 +0200
fred <[hidden email]> 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
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Lazarus - fpc 3

Craps
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


Le lundi 11 juillet 2016 à 22:55 +0200, Mattias Gaertner a écrit :

> On Mon, 11 Jul 2016 21:14:48 +0200
> fred <[hidden email]> 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


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Lazarus - fpc 3

Michael Van Canneyt


On Mon, 11 Jul 2016, fred wrote:

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

:-)

Codetyphon is a customized version of Lazarus, not the other way round :)

Michael.
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Lazarus - fpc 3

Mattias Gaertner
In reply to this post by Craps
On Mon, 11 Jul 2016 23:05:29 +0200
fred <[hidden email]> wrote:

> 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
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Lazarus - fpc 3

Craps
In reply to this post by Michael Van Canneyt
Hy,

can i install lazarus (recently version) on Haiku ?

Friendly
Frédéric

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Lazarus - fpc 3

Craps
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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Giuliano Colla
In reply to this post by leledumbo
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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Mattias Gaertner
On Tue, 12 Jul 2016 19:21:36 +0200
Giuliano Colla <[hidden email]> wrote:

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

 

> 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
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Giuliano Colla
Il 13/07/2016 14:06, Mattias Gaertner ha scritto:
What compiler is now called?

fpc->ppcarm 2.6.4

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

That's the big question I'm unable to understand. The full picture is:

  1. /home/colla/Applicazioni/lazarus/fpc/binutils/as is there (it's actually a symlink to /usr/local/bin/arm-linux-as). If I invoke it manually it assembles properly
  2. Manually compiling fcllaz.pas with minimal parameters: fpc -Tlinux -Parm -XParm-linux- -B -a -va fcllaz.pas >out.txt works just fine.
  3. Specifying the proper CPU type works just fine: fpc -Tlinux -Parm -CpARMV7 -XParm-linux- -B -va fcllaz.pas >out1.txt
  4. 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
  5. 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".
  6. 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.
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.
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?

Giuliano


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus

lazout.txt (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] [SOLVED!]Unable to cross-compile Lazarus applications in Linux from x86_64 to arm target (Raspberry pi 3)

Giuliano Colla
In reply to this post by Mattias Gaertner
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


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Mattias Gaertner
In reply to this post by Giuliano Colla
On Wed, 13 Jul 2016 19:36:23 +0200
Giuliano Colla <[hidden email]> wrote:

> 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
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Giuliano Colla
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



--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] [SOLVED!]Unable to cross-compile Lazarus applications in Linux from x86_64 to arm target (Raspberry pi 3)

Joost van der Sluis
In reply to this post by Giuliano Colla
Op 13-07-16 om 19:54 schreef Giuliano Colla:
> 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.
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] [SOLVED!]Unable to cross-compile Lazarus applications in Linux from x86_64 to arm target (Raspberry pi 3)

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

> 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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus