Forum > General

Cross Compiling

(1/2) > >>

J-G:
Having updated to Laz 2.2.0 ( I see 2.2.2 is now available!!) from Laz 1.6, simply to take advantage of resizing 'Hints', I would also not like to compile for use on Linux, Mac and posibly Android.

Now, I may well be naïve and completely mis-understand the distinction between Cross-Platform & Cross-Compling but I would appreciate guidance.

I'm using Windows 7 64 bit, I can create 64bit & 32bit programs simply by changing the 'Target CPU Family' in the [Project Options] but If I select (say) MacOS as the 'Target OS' leaving the CPU family as [Default] - I get a warning that the current FPC has no config file.

I can understand that I would need to install some 'add-on' and I would expect this to be a 'Cross-Compiler' but I haven't been able to find such on Laz or FPC sites. It's possible that I've been looking for the wrong thing or even in the wrong place but with so many 'Options' I'm simply at a loss as to know what I should be looking for.

A similar situation exists of course for Linux & Android.

Can someone enlighten me please?

wp:
For me, "cross-compilation" is largely overestimated. Even if it creates a valid binary for the destination platform you cannot necessarily run and test the application on that platform. And believe me, tiny changes in code working on your normal platform can have unwanted effects on another platform.

Therefore, rather than cross-compiling I have set up virtual machines and installed the other OSes on them. On these VMs I installed Lazarus again. This way I can compile and test the application like on my normal platform.

The VMs are always set up so that there is access to the code base on the normal platform.

I did use cross-compilation, so far, for rare activities with WinCE and Arduino. In this case, I used FPCUpDeluxe to install Lazarus and prepare it for cross-compilation since FPCUpDeluxe can get the required libraries very easily (https://wiki.freepascal.org/fpcupdeluxe#Cross-compiling).

Zvoni:
It starts with reading the Wiki
https://wiki.freepascal.org/Cross_compiling

EDIT: But i agree with wp:
Setup VM's (e.g VirtualBox) with the Target-OS/Bitness, install Lazarus/FPC there.
Done correctly, you don't have to move your sourcecode around

Beware: AFAIK, there are legal issues when running MacOS as a guest in a VM

J-G:
Thanks both,

You've essentiall confirmed what I had surmised  -  It ain't easy  -  :D

In fact there is no way that want MacOS anywhere near my PCs ;D  Linux might be another matter but I suspect that if I did go down that route it would be on a separate PC so could install Laz for Linux  -  and I'm sure that would throw up even more complications which would be totally outside my comfort zone  %)

I'll leave well alone!

This does beg the question about the [Project Options] [Config and Target] [Target Platform] drop-down lists though - why - on a Win 64bit installation - is it posible to select 'Android', 'BeOS',  'Java', 'Linux' . . . ?   

Maybe these questions would be answered if I read the [Cross-compiling] Wiki  ;D

trev:

--- Quote from: wp on May 19, 2022, 04:03:48 pm ---For me, "cross-compilation" is largely overestimated. Even if it creates a valid binary for the destination platform you cannot necessarily run and test the application on that platform.
--- End quote ---

All my Windows compilation is done on macOS. I've not run into any issues with the produced executables failing in Windows. I do it because it is very convenient (and needed no additional tools other than the normal FPC + Lazarus). FreeBSD and Linux compilation is done in their own VMs with a full FPC + Lazarus installation from source.


--- Quote --- And believe me, tiny changes in code working on your normal platform can have unwanted effects on another platform.
--- End quote ---

I do always test the produced executables in multiple Windows VMs (2000, XP, XP-64, 10-64, 11-64) running in Parallels on macOS.

Navigation

[0] Message Index

[#] Next page

Go to full version