Lazarus

Programming => Operating Systems => Other => Topic started by: ertank on December 11, 2019, 06:20:13 am

Title: Cross compile from Win10 to Raspberry Pi
Post by: ertank on December 11, 2019, 06:20:13 am
Hello,

I wonder if it is possible to cross compile from Windows 10 to Raspberry Pi.

I know it is possible to run Lazarus itself on Pi. However, there are times I do love to do cross compiling where possible.

Thanks & regards,
Ertan
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: Thaddy on December 11, 2019, 06:36:18 am
Short answer: YES.
Long answer: you need to obtain a toolchain - binutils -for the Pi and copy some files from the Pi itself. And both the wiki and this forum contain all the answers to get you going.
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: SirTwist on December 20, 2019, 09:30:00 pm
Funny... I justed started with the same challenge and studied all the wiki pages etc...

I downloaded the FPC 3.0.4 sources, modified the batch file from the "Lazarus_on_Raspberry_Pi" page.
Compiler compilation and installation works fine.

But when I try to set another plattform on an existing project, I got following messages (originally in German, trying to translate)
Code: Pascal  [Select][+][-]
  1. Compiling Package FCL 1.0.1: Exit code 1, Fehler: 1, Hinweise: 2
  2. Hint: Start of reading config file X:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.cfg
  3. Hint: End of reading config file X:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.cfg
  4. Verbose: Free Pascal Compiler version 3.0.4 [2019/12/20] for arm
  5. Verbose: Copyright (c) 1993-2017 by Florian Klaempfl and others
  6. Verbose: Target OS: Linux for ARMEL
  7. Verbose: Compiling fcllaz.pas
  8. Verbose: PPU Loading X:\lazarus\fpc\3.0.4\units\arm-linux\rtl\system.ppu
  9. Verbose: Trying to use a unit which was compiled with a different FPU mode
  10. Fatal: Cannot find system used by fcllaz. Please make sure, that all .ppu-Dateien of a packages are in that output directory. ppu in wrong directory=X:\lazarus\fpc\3.0.4\units\arm-linux\rtl\system.ppu..
  11. Verbose: Compilation aborted
  12. Verbose: X:\lazarus\fpc\3.0.4\bin\x86_64-win64\ppcrossarm.exe returned an error exitcode

Has anyone an idea what I missed here?

ertank: had you any success?

Kind regards,
Michael
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: af0815 on December 20, 2019, 10:23:05 pm
I wonder if it is possible to cross compile from Windows 10 to Raspberry Pi.
No problem, if you want to use fpcupdeluxe on windows.

After the basic installation, it downloads the correct crossbuild chain for you and make the system workable. I use it for crossbuild for arm-linux and x64-linux. One goal for you is, to have the correct libraries depending on the used components on the windows machine. this can sometime be a little tricky to find out, what is missing and the needed depencies. 
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: ertank on December 20, 2019, 11:04:57 pm
ertank: had you any success?

I did not have time to look at it, unfortunately.
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: ertank on December 20, 2019, 11:08:00 pm
No problem, if you want to use fpcupdeluxe on windows.

After the basic installation, it downloads the correct crossbuild chain for you and make the system workable. I use it for crossbuild for arm-linux and x64-linux. One goal for you is, to have the correct libraries depending on the used components on the windows machine. this can sometime be a little tricky to find out, what is missing and the needed depencies.

Actually, I only use fpcupdeluxe for setting up Lazarus & fpc. I am not sure which cross build options I should be selecting for ARMHF builds. Would you share some screen captures, please?

Thanks.
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: mas steindorff on December 20, 2019, 11:25:45 pm
The error looks like you have either selected the wrong CPU or you need to do a clean and build to generate new .ppu files
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: SirTwist on December 21, 2019, 12:41:11 pm
The error looks like you have either selected the wrong CPU or you need to do a clean and build to generate new .ppu files

This is the (modified) batch file I used to compile FPC:
Code: [Select]
%FPCBIN%\make distclean OS_TARGET=linux CPU_TARGET=arm  CROSSBINDIR=%FPCCROSSBIN% CROSSOPT="-CpARMV6 -CfVFPV2 -OoFASTMATH" FPC=%FPCMBIN%\ppcx64.exe
%FPCBIN%\make all OS_TARGET=linux CPU_TARGET=arm CROSSBINDIR=%FPCCROSSBIN% CROSSOPT="-CpARMV6 -CfVFPV2 -OoFASTMATH" FPC=%FPCBIN%\ppcx64.exe
if errorlevel 1 goto quit
%FPCBIN%\make crossinstall CROSSBINDIR=%FPCCROSSBIN% CROSSOPT="-CpARMV6 -CfVFPV2 -OoFASTMATH" OS_TARGET=linux CPU_TARGET=arm FPC=%FPCBIN%\ppcx64.exe INSTALL_BASEDIR=%OUTPATH%
It first makes a distclean. I also tried to remove all "arm-linux" directories within the lazarus/fpc directory. Didn't helped.

Any more ideas?

Kind regards,
Michael
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: Leledumbo on December 23, 2019, 10:14:52 am
For ARM, it's rather complicated. The resulting compiler doesn't carry a bunch of CPU/ABI/FPU mode used to build it, instead it has its own default. Therefore, you have to use the same set of options when building your project.

On a side note, I belive on RPi, if you use Raspbian, you will need to target ARMHF instead of ARMEL.
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: Thaddy on December 23, 2019, 11:38:21 am
For ARM, it's rather complicated.
No it is not. You just need the proper binutils and know how to build a cross-compiler.
Quote
On a side note, I belive on RPi, if you use Raspbian, you will need to target ARMHF instead of ARMEL.
Yes that is correct.

https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Cross_compiling_for_the_Raspberry_Pi_from_Windows
https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/
Title: Re: Cross compile from Win10 to Raspberry Pi
Post by: Leledumbo on December 23, 2019, 01:30:07 pm
No it is not. You just need the proper binutils and know how to build a cross-compiler.
Well, the fact that this thread exists say otherwise. The OP expects to use fpc as is, just like in other targets, but he couldn't due to missing options he used to build the compiler and the entire rtl + packages.
TinyPortal © 2005-2018