Recent

Author Topic: Cross Compile - Linux to Windows & ARM  (Read 1929 times)

DelphiDinosaur

  • New member
  • *
  • Posts: 6
Cross Compile - Linux to Windows & ARM
« on: November 18, 2021, 03:56:45 pm »
Hello.
My first post here.
I've been developing with Delphi6 and XE for 10+ years but have recently been tasked to convert an existing windows dll project into a Linux .so to run on a Varascite ARM 7-A (Dart-6UL-5G), hence the switch to Lazarus.

I've been able to modify the Delphi-XE code to compile for Windows using Lazarus running on Windows. I'd hoped that it would be a simple task to cross compile for the ARM on Windows  :-[.

To simplify my task I switched to running Lazarus on Ubuntu, thinking the cross compile would be easier. I'm running Ubuntu 20.04.3 LTS and have installed the 64 bit version (FPC v3.2.0 and Lazarus 2.0.12) via the .deb files using gdebi. (I should point out I'm also quite new to the Linux OS).

Compiling a basic "hello world" program (GUI and console based) was quite straight forward so I moved onto attempting cross compiling.

By following the instructions here I was able to compile for desktop Linux and Windows (GUI, console and dll) without any major problems.

However, I'm really struggling to cross compile for the ARM. I've found various "instructions" but I've been unable to follow any of them successfully. They're often referring to older versions of FPC or Lazarus and appear to assume you know what you're doing and installing/building manually rather than using the .deb files and the automatic install.

By shear luck I've managed to get a terminal program compiling for the arm but have no idea how I managed it - I've certainly not been able to repeat making a working build environment on VMs or a fresh install of Unbuntu.
I've even re-working the cross compiling for Windows with commands these lines:
Code: [Select]
make clean all OS_TARGET=linux CPU_TARGET=arm
make crossinstall OS_TARGET=linux CPU_TARGET=arm INSTALL_PREFIX=/usr
ln -sf /usr/lib/fpc/"$FPCVER"/ppcrossarm /usr/bin/ppcrossarm

However, running these on a clean install leaves me with Lazarus that will compile for Linux desktop and Windows but not ARM.


Is there a set of instructions to follow for configuring cross-compilation for ARM using the basic installation?

« Last Edit: November 18, 2021, 04:13:56 pm by DelphiDinosaur »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9981
  • FPC developer.
Re: Cross Compile - Linux to Windows & ARM
« Reply #1 on: November 18, 2021, 04:47:42 pm »
Basically, try your luck with some prebuild crossbuiliding solution (fpcdeluxe, the project that shall not be named), or forget about easy and dive into the rabbit hole.

The problem is that more advanced crosscompiling is that there are many difficult details. Linux requires libraries to link against on host, so the ARM libraries should be on the i386 machine , and care must be taken to avoid that the linker sees the native host ones.

Since no two Linux installations are exactly the same, making a simple recipe like install difficult. All sides (Lazarus itself, host Linux (or the tools used on Windows) and target linux) are variable

The simplest diagnosing of problems also requires knowledge.

I tried to make a general,easy recipe long ago, but miserably failed, and went for a more background documentation. It is called the buildfaq and even while out of date, it is a start.

DelphiDinosaur

  • New member
  • *
  • Posts: 6
Re: Cross Compile - Linux to Windows & ARM
« Reply #2 on: November 19, 2021, 04:47:16 pm »
Thanks for your suggestion @marcov. fpcupdeluxe got me going quicker on the VM than trying to install Laz, fpc and the cross compiler manually.

I can now quickly generate a console app that compiles for arm and x64 without any problems.

Now to get the library project recognised by arm!

DD.

 

TinyPortal © 2005-2018