Recent

Author Topic: Cross compiling  (Read 5643 times)

geraldholdsworth

  • Full Member
  • ***
  • Posts: 195
Cross compiling
« on: February 20, 2022, 11:44:12 am »
I've previously been compiling my Lazarus applications by firing up the appropriate OS and compiling for that OS. This means on my Mac I've got VirtualPC with Windows 10 and Linux, and, separately, a RaspberryPi.

I've recently managed to get Lazarus on my Mac to cross-compile to Windows (32 and 64 bit), and (with Lazarus 2.2), to cross compile for the new macOS. But, I've lost the ability to cross-compile to 32 bit macOS. It complains with:
graphics.pp(69,14) Fatal: Cannot find GraphMath used by Graphics, incompatible ppu=/Users/geraldholdsworth/.lazarus/lib/LazUtils/lib/i386-darwin/graphmath.ppu, multiple packages: LazUtils, LCLBase
even though this package is not used in the project (neither are the LazUtils or LCLBase).

OK, that's the first problem.

The next is trying to cross compile to Linux - I'm after 32 bit, 64 bit and ARM. So, I installed FINK. Then ran the command to install the cross compile package for both ARM and 32 bit (so far). Then, when I come to compile for either of these, it complains with:
Fatal: Cannot find system used by fcllaz of package FCL.
This is using the same Config and Path option that does work running on Linux.

So, I'm thinking that fink, having taken hours to install, is next to useless. As are the two packages I installed. And I can't even find an option to uninstall fink.

mischi

  • Full Member
  • ***
  • Posts: 170
Re: Cross compiling
« Reply #1 on: February 20, 2022, 02:05:34 pm »
Hi.

I maintain the fink packages and are sorry for your bad experience. I have much interest to sort this out. As I see, you are interested in these targets: i386-darwin, i386-win32, x86-64-win64, i386-linux, x86-64-linux and arm-linux. Let me get into details:

i386-darwin:
What system and version of Xcode are you using? This is important, because Apple removed the 32bit assembler and linker at some version. At least with version 10, it should work still work.

i386-win32 and x86-64-win64:
These targets are the easiest, because fpc uses its internal assembler and linker. Even Lazarus and Lazarus projects should work.

i386-linux, x86-64-linux and arm-linux:
These depends on crossbinutils (assembler and linker), which are installed through fink. However, only pure Pascal projects will work out of the box. Lazarus for these platforms needs other libraries, in particular GTK. In principle this is possible, but the task was too demanding for me. One needs to copy all libraries required from a corresponding linux distro. This is independent, whether you use a package manager like fink or do everything manually.

As a first step, I would target x86-64-win64. Are you willing to support me? The first step is to compile a small ('Hello World') test program on the command line for the platform and check whether this runs and then work the way up step by step as far as you need it. I managed to create simple Lazarus projects. Similarly for i386-darwin.

All the best - Michael Schindler.

geraldholdsworth

  • Full Member
  • ***
  • Posts: 195
Re: Cross compiling
« Reply #2 on: February 20, 2022, 04:25:06 pm »
Hi Michael,

When I upgraded my Mac from High Sierra to Catalina, I managed to get Lazarus (then v2.0.12) to cross compile for i386-darwin. It's only since I've upgraded Lazarus to v2.2 that I've lost it - although I have managed to cross-compile another project for 32 bit macOS. For this, I think I just need compatible units...just unsure where to get them as 2.0.12 is the latest version for 32 bit macOS (although, I have come across this, but I'm unsure what it is for).

The two Windows cross-compilers, as you say, are the easiest and I have managed to get those working. It is just the Linux targets which is proving to be an issue.

I have Lazarus 2.2 installed on both a Linux Virtual machine and on my RaspberryPi, so grabbing any needed files shouldn't be too much of an issue. I just need to know which files to grab (from where) and where to put them.

I'm sure fink is a fabulous piece of software, but it just hasn't done anything for me, apart from take up hard drive space. I even tried the GUI version (I presume it was, downloaded from the website), but even this wouldn't install.

Cheers,

Gerald.

geraldholdsworth

  • Full Member
  • ***
  • Posts: 195
Re: Cross compiling
« Reply #3 on: February 20, 2022, 05:57:46 pm »
Interestingly, I've just been on to my Linux install to see if I can figure out what files I might need on macOS, and I can no longer cross compile to Linux 32 bit either - same error as on macOS when I cross-compile to macOS 32 bit...

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2023
  • Former Delphi 1-7, 10.2 user
Re: Cross compiling
« Reply #4 on: February 20, 2022, 10:47:41 pm »
But, I've lost the ability to cross-compile to 32 bit macOS.

Apple removed the Carbon framework from macOS 10.15 Catalina (2019) - that operating system and future versions will not execute any 32 bit software at all.

The last versions of macOS and Xcode which had the necessary Apple files to compile 32 bit applications was Mojave 10.14.x and Xcode 11.3.1.

So, the simplest solution is to use Mojave for 32 bit applications.

On the other hand I have to question why you need 32 bit macOS applications at all - every Apple computer since the switch to Intel processors since late 2006 has a 64 bit capable processor and the Cocoa framework has been available since Panther 10.3 (2003) with a significant extension in Tiger 10.4 (2005).
« Last Edit: February 20, 2022, 10:51:34 pm by trev »

geraldholdsworth

  • Full Member
  • ***
  • Posts: 195
Re: Cross compiling
« Reply #5 on: February 20, 2022, 10:55:19 pm »
I did manage to compile 32 bit macOS until I upgraded Lazarus to 2.2 a few weeks back - there was a small command I put into the Project Options (details in another thread).

However, with regard your question - I am considering the possibility of not compiling for this architecture, because of the reasons you state. If I can't find a way of doing this, then that is decision made - I won't be expending too much energy on this particular problem. Cross-compiling for Linux, however, I still need to do (although I am wondering if 32 bit Linux binaries are needed).

dbannon

  • Hero Member
  • *****
  • Posts: 2802
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cross compiling
« Reply #6 on: February 21, 2022, 03:36:50 am »
In terms of getting ARM compiled, maybe https://wiki.freepascal.org/Cross_Compile_to_RasPi_from_Linux will help, its obviously how to do it from Linux but does detail the underlying stuff thats needed, in particular about getting the libraries in place.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Seenkao

  • Hero Member
  • *****
  • Posts: 550
    • New ZenGL.
Re: Cross compiling
« Reply #7 on: February 21, 2022, 06:23:29 am »
Cross-compiling for Linux, however, I still need to do (although I am wondering if 32 bit Linux binaries are needed).
32-х битная система используется по сей день. Насколько сильно это используется в Linux, надо проводить опросы среди населения, которое мало выходит в интернет.
Google translate: The 32-bit system is still in use today. How heavily this is used in Linux, it is necessary to conduct surveys among the population that does not go online much.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2023
  • Former Delphi 1-7, 10.2 user
Re: Cross compiling
« Reply #8 on: February 21, 2022, 10:24:12 am »
According to the release notes for Xcode 10: "The macOS 10.14 SDK no longer contains support for compiling 32-bit applications. If developers need to compile for i386, Xcode 9.4 or earlier is required. (39858111)"

However I was still building 32 bit Lazarus and FPC with Mojave and Xcode 11.3.1 in October 2020 (I still have the scripts). I have just created a new Mojave VM and with this version of Xcode command line tools:

Quote
$ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
version: 10.3.0.0.1.1562985497

and I can still recompile the i386 version of FPC 3.2.0 provided I use the previous macOS 10.13 SDK, not the 10.14 SDK.

No SDK version works on Monterey because of invalid (i386) CPU instructions.
« Last Edit: February 21, 2022, 10:30:38 am by trev »

geraldholdsworth

  • Full Member
  • ***
  • Posts: 195
Re: Cross compiling
« Reply #9 on: February 21, 2022, 07:41:53 pm »
However I was still building 32 bit Lazarus and FPC with Mojave and Xcode 11.3.1 in October 2020 (I still have the scripts). I have just created a new Mojave VM and with this version of Xcode command line tools:
I managed it by putting
Code: [Select]
-XR/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/in the Custom Options on the Project Options. It's only since I upgraded to Lazarus 2.2 (and, presumably FPC 3.2.2) does it now not work.

geraldholdsworth

  • Full Member
  • ***
  • Posts: 195
Re: Cross compiling
« Reply #10 on: February 21, 2022, 07:42:41 pm »
The 32-bit system is still in use today. How heavily this is used in Linux, it is necessary to conduct surveys among the population that does not go online much.
I wonder if I stop supplying the 32 bit binaries, how many people then complain - then I'll know!  :D

dbannon

  • Hero Member
  • *****
  • Posts: 2802
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cross compiling
« Reply #11 on: February 22, 2022, 02:44:43 am »
I have a very small Mac user base for my app, I estimate less than 200. I stopped the 32bit version several years ago and did not get a single complaint.

On the other hand, if I put out a beta without the (obviously 64bit) Mac included, I do hear from them ....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

geraldholdsworth

  • Full Member
  • ***
  • Posts: 195
Re: Cross compiling
« Reply #12 on: February 22, 2022, 12:02:21 pm »
OK, situation so far:
  • 32 bit macOS - given up, for now, maybe forever (there is no 3.2.2 FPC available on this platform)
  • Linux - I have downloaded both fpc.rpm files, for FPC 3.2.2, extracted all the files, and copied the contents of usr/lib/fpc/3.2.2/fpminst/i386-linux, usr/lib/fpc/3.2.2/units/i386-linux, usr/lib64/fpc/3.2.2/fpminst/x86_64-linux, and usr/lib64/fpc/3.2.2/units/x86_64-linux to /usr/local/lib/fpc/3.2.2/fpmkinst and /usr/local/lib/fpc/3.2.2/units respectively. This gets me further, but errors out with "Error: Util x86_64-linux-ld not found, switching to external linking" (or i386-linux-id). I can't copy the ppc386 or ppcx64 files as this is what macOS uses.
  • ARM Linux - haven't looked into this one yet.
Any suggestions are very welcome.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1739
Re: Cross compiling
« Reply #13 on: February 22, 2022, 12:21:16 pm »
Shameless plug. You might try to use fpcupdeluxe for your task. OSX 32 bit binaries can still be cross-build.

geraldholdsworth

  • Full Member
  • ***
  • Posts: 195
Re: Cross compiling
« Reply #14 on: February 22, 2022, 12:40:08 pm »
Shameless plug. You might try to use fpcupdeluxe for your task. OSX 32 bit binaries can still be cross-build.

I don't think it is shameless - I linked to it in an earlier post but was unsure of what it is/does.

 

TinyPortal © 2005-2018