Cross compiling lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- geraldholdsworth · 2022-02-20 10:44 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/i38 6-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 · 2022-02-20 13:05 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 · 2022-02-20 15:25 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 · 2022-02-20 16:57 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 · 2022-02-20 21:47 Quote from: geraldholdsworth on February 20, 2022, 11:44:12 amBut, 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). ---------------------------------------------------------------------- geraldholdsworth · 2022-02-20 21:55 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 · 2022-02-21 02:36 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 ---------------------------------------------------------------------- Seenkao · 2022-02-21 05:23 Quote from: geraldholdsworth on February 20, 2022, 10:55:19 pmCross- 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. ---------------------------------------------------------------------- trev · 2022-02-21 09:24 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. ---------------------------------------------------------------------- geraldholdsworth · 2022-02-21 18:41 Quote from: trev on February 21, 2022, 10:24:12 amHowever 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 · 2022-02-21 18:42 Quote from: Seenkao on February 21, 2022, 06:23:29 amThe 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! ---------------------------------------------------------------------- dbannon · 2022-02-22 01:44 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 ---------------------------------------------------------------------- geraldholdsworth · 2022-02-22 11:02 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 · 2022-02-22 11:21 Shameless plug. You might try to use fpcupdeluxe for your task. OSX 32 bit binaries can still be cross-build. ---------------------------------------------------------------------- geraldholdsworth · 2022-02-22 11:40 Quote from: DonAlfredo on February 22, 2022, 12:21:16 pmShameless 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. ---------------------------------------------------------------------- DonAlfredo · 2022-02-22 12:01 Short instruction. Download fpcupdeluxe suitable for your system. Run fpcupdeluxe. Select an install directory. Give it an appropriate name. Click install/update FPC + Lazarus. While enjoying the output screen, drink a coffee and eat a sandwich. When finished, you have an isolated FPC + Lazarus install. Close fpcupdeluxe. Check the FPC + Lazarus install. Run fpcupdeluxe. Select the cross tab. Select the desired CPU and OS. Click install cross-compiler. In most cases, after a while, you will get an error due to missing tools and libs. Let fpcupdeluxe handle the install of both. When all is finished, crossing to selected CPU/OS should be possible. Sidenote. During use of fpcupdeluxe, many things can go wrong. Search the forum or github for similar issues. Not found: use github to create an issue. ---------------------------------------------------------------------- geraldholdsworth · 2022-02-22 12:33 Sounds ideal - do I need to uninstall my current Lazarus/FPC install first, or just go for it? ---------------------------------------------------------------------- DonAlfredo · 2022-02-22 12:40 Go for it ... ;-) ---------------------------------------------------------------------- geraldholdsworth · 2022-02-22 13:44 I downloaded the FPC updeluxe for x86_64 cocoa, and ran it. First thing was an Access Violation. Clicked OK to continue and got the attached screen. I selected a directory (on the Desktop, for now), then clicked on Install/Update FPC+Laz and got told to select a version first...but from where? So, I went to the Cross tab - ah, there are options. Selected i386 and Linux, then clicked on Install Compiler...Access violation, and nothing happened. This is running from both the Downloads directory and moving into the same Applications directory as Lazarus itself - same result both times. I even tried the qt5 version, which gave even more Access violation errors. ---------------------------------------------------------------------- DonAlfredo · 2022-02-22 14:30 This seems to be a permission error on your system. Has been reported before. My advice. Please create a dedicated directory for fpcupdeluxe. And run fpcupdeluxe from this directory. And install FPC + Lazarus into this directory. This keeps fpcupdeluxe and your install together. But again: please check your permissions. Fpcupdeluxe need to create some files and this is not working for you [yet]. ---------------------------------------------------------------------- geraldholdsworth · 2022-02-22 14:41 Created a directory on the Desktop, copied the app into it, changed the permissions to Read&Write for all (on the directory), then ran it...looking promising so far. ---------------------------------------------------------------------- geraldholdsworth · 2022-02-22 16:08 All works - at least on the project I was using as test. So thank you. I can now compile to 8 different systems. I did notice that my cross- compile to 32 bit macOS, on my main Lazarus install, started working after I'd installed the compiler in FPC Deluxe...but the Linux ones still didn't, after I'd done those. So, next job - setup the new Lazarus install with my preferences (or maybe just find a way to migrate them from the main install). And then maybe remove the main install - bit nervous about that, in case it removes some of the FPC installed version...I suppose I can always re- do it! Oh, and I need to work out how to uninstall fink...don't need that anymore (sorry). ---------------------------------------------------------------------- mischi · 2022-02-23 13:44 Removing fink is pretty simply, since as much as possible it is contained in a separate folder. On older systems it is /sw, on newer ones /opt/sw. Then there is the folder "Fink" in /Applications. Delete them from the command line or by moving them to the trash can and empty it. All the best - Michael. ---------------------------------------------------------------------- geraldholdsworth · 2022-02-23 13:48 Cool - thank you Michael. I did find the /opt/sw folder but was nervous to delete the whole thing, just in case. I have no fink folder in /Applications though. ---------------------------------------------------------------------- mischi · 2022-02-23 17:14 Quote from: geraldholdsworth on February 23, 2022, 02:48:42 pmI have no fink folder in /Applications though. The folder /Applications/Fink is only created and filled, if a package requires it.