Lazarus

Installation => Windows (32/64) => Topic started by: Grahame Grieve on September 28, 2020, 10:12:46 pm

Title: Compiling for OSX from Windows
Post by: Grahame Grieve on September 28, 2020, 10:12:46 pm
I'm trying to figure out how to get my win64 install of lazarus to compile for macos. I'm using FPCUPdeluxe, and I have other windows + linux installed. Versions= 2.1.0/3.3.1 and fpcupdeluxe is 1.8.0e.

from FPCUPdeluxe, I assume that darwin = macos?

I choose x64 + darwin, and I get:

    Be forwarned: this will only work with FPC 3.2 / embedded / trunk.

That tells me very little:
*  What's embedded / trunk?
* does 3.2 only mean, not prior to 3.20? or only 3.2?
* does the dialog mean that this will or won't work? will nothing get installed, or 3.2 instead of 3.3.1? or something else?

So say yes anyway, and it proceeds to do a whole bunch of work and says that it succeeded. But then, if I choose x64/macos in Lazarus, it tells me that there's no config for this option

What should I do to be able to compile for OSX from windows?
Title: Re: Compiling for OSX from Windows
Post by: trev on September 29, 2020, 04:48:27 am
Cross-compiling for macOS on Windows is certainly the road less travelled. The Wiki has no instructions for doing this unfortunately.

I believe Don Alfredo, the author of fpcupdeluxe, compiles his macOS binaries on Windows and may be able to offer some insight.

You will of course run into the issue of not being able to test your macOS binaries if you do not have access to an Apple computer.

[Going the other way, macOS to Win32 or to Win64 is trivial in comparison and is what I do. Win binaries are then tested in Parallels VMs.]
Title: Re: Compiling for OSX from Windows
Post by: Grahame Grieve on September 29, 2020, 05:50:02 am
Well, I'm also working on setting up Lazarus on MacOS. That doesn't seem like a road very well travelled either. Certainly the instructions are obtuse, and/or out of date.

Of course I will need a mac to actually run anything.
Title: Re: Compiling for OSX from Windows
Post by: trev on September 29, 2020, 07:01:19 am
Well, I'm also working on setting up Lazarus on MacOS. That doesn't seem like a road very well travelled either. Certainly the instructions are obtuse, and/or out of date.

The instructions for installing Lazarus on macOS (https://wiki.freepascal.org/Installing_Lazarus_on_macOS) are completely up to date. What is obtuse about them?
Title: Re: Compiling for OSX from Windows
Post by: DonAlfredo on September 29, 2020, 10:05:25 am
All fpcup binaries are (cross-)compiled on a Windows 10 machine. Including binaries for macOS (=Darwin).

Embedded is a repo that is in sync with trunk, but with some extras that allow me to build for SAMC and SAMD micro-controllers. So, embedded=trunk.
And you are right: stating just 3.2 is not very clear. It means at least 3.2, including trunk.

So, you are welcome to use fpcupdeluxe to setup FPC and Lazarus and also use it to setup cross-compiling towards macOS. If you encounter issues, please report them on GitHub. I have to restart my work on fpcupdeluxe (have been a bit busy lately), but your issue will be addressed.

Pease note:
At the moment FPC 3.2.1 and newer will not (cross-)build for Darwin i386 anymore due to some incompatible mnemnonics that are generated by the compiler. Due to this issue, my personal build-system at the moment for fpcupdeluxe binaries is based on FPC stable and Lazarus trunk. Both with some minor changes to be able to cross-compile towards all those different architectures.

Edit:
The patches that are used are out in the open.
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/patches_v1.0
If enabled (in Setup+), the suitable patches will be automagically applied by fpcupdeluxe.
Title: Re: Compiling for OSX from Windows
Post by: Grahame Grieve on September 29, 2020, 12:49:16 pm
Well, I'm not sure what to report. Here's the results out of FOCUPdeluxe:

---------------------------------------------------------------------------------

Going to install a cross-compiler from available sources.
Fpcupdeluxe: FPC cross-builder: Building compiler for darwin-x86_64.
FPCUP(deluxe) is starting up.

Binutils/make dir:     C:\tools\lazarus\fpcbootstrap
Bootstrap dir:         C:\tools\lazarus\fpcbootstrap
FPCupdeluxe basedir:   C:\tools\lazarus
FPC URL:               https://svn.freepascal.org/svn/fpc/trunk
FPC options:           
FPC source directory:  C:\tools\lazarus\fpcsrc
FPC install directory: C:\tools\lazarus\fpc
Lazarus URL:               https://svn.freepascal.org/svn/lazarus/trunk
Lazarus options:           
Lazarus source directory:  C:\tools\lazarus\lazarus
Lazarus install directory: C:\tools\lazarus\lazarus

Please stand back and enjoy !

29/09/2020 6:09:36: fpcupdeluxe: V304 (20200722) started.
FPCUPdeluxe V1.8.0e for x86_64-win64 running on Win64-10.0.18363

... (lots of build)....

fpcupdeluxe: info: FPCCrossInstaller (BuildModuleCustom: FPC): Adding fpc.cfg config snippet for target x86_64-darwin
fpcupdeluxe: info: FPCCrossInstaller (InsertFPCCFGSnippet: fpc.cfg): Found existing snippet in C:\tools\lazarus\fpc\bin\x86_64-win64\fpc.cfg. Replacing it with new version.
fpcupdeluxe: info: FPCCrossInstaller (InsertFPCCFGSnippet: fpc.cfg): Inserting snippet in C:\tools\lazarus\fpc\bin\x86_64-win64\fpc.cfg done.
fpcupdeluxe: info: FPCCrossInstaller (BuildModuleCustom: FPC): Building native compiler for x86_64-darwin finished.
fpcupdeluxe: info: FPCCrossInstaller (BuildModuleCustom: FPC): Removal of stale build files and directories ready.
fpcupdeluxe: info: FPCCrossInstaller (BuildModuleCustom: FPC): Removal of stale build files and directories ready.


SUCCESS: Fpcupdeluxe ended without errors.

---------------------------------------------------------------------------------

So shouldn't that mean that lazarus should be able to compile for MacOS now? Because it just says that it can't. Is there something I can look for?
Title: Re: Compiling for OSX from Windows
Post by: Grahame Grieve on September 29, 2020, 12:52:33 pm
> The instructions for installing Lazarus on macOS are completely up to date

well, for the command line tools, they should just say 'this doesn't work on catalina'.

The real problem, though, is svn. I installed svn using homebrew but it still doesn't work. Which appears to mean that you can only install 3.2.0/2.0.10 on macos via the .git - and I only found any reference to that on the forum somewhere. (I think I need 3.3.1/2.1.0)

I was going to make another post about that in the right group. I created a brand new vanilia catalina to test the install process. Because even after it succeeds for I can't recompile the IDE. But I'll make another post about that
Title: Re: Compiling for OSX from Windows
Post by: Grahame Grieve on September 29, 2020, 12:57:39 pm
> The real problem, though, is svn

That's a problem with FPCUPdeluxe. Not directly with those instructions. Anyway, I'll make another post about MacOS install.
Title: Re: Compiling for OSX from Windows
Post by: trev on September 29, 2020, 01:00:32 pm
The real problem, though, is svn. I installed svn using homebrew but it still doesn't work. Which appears to mean that you can only install 3.2.0/2.0.10 on macos via the .git - and I only found any reference to that on the forum somewhere. (I think I need 3.3.1/2.1.0)

The instructions I pointed you to include instructions for using either svn or git. There are also instructions in the same place for installing non-release versions of both Lazarus and Free Pascal.
Title: Re: Compiling for OSX from Windows
Post by: DonAlfredo on September 29, 2020, 01:40:52 pm
Quote
So shouldn't that mean that lazarus should be able to compile for MacOS now? Because it just says that it can't. Is there something I can look for?
Yes, it should be able. Please elaborate on this issue.
Title: Re: Compiling for OSX from Windows
Post by: Grahame Grieve on September 29, 2020, 09:46:31 pm
I've attached a screenshot of what happens if I try to choose macos as a compiler target after the fpcupdeluxe run above.

My install directory is C:\tools\lazarus. In C:\tools\lazarus\fpc. I have these folders in there:
x86_64-linux
x86_64-win64
i386-win32
x86_64-darwin

but the C:\tools\lazarus\fpc\bin only has
i386-win32
x86_64-linux
x86_64-win64

Only the x86_64-win64 has an fpc.cfg file. I'm not sure what else to look for
Title: Re: Compiling for OSX from Windows
Post by: DonAlfredo on September 29, 2020, 10:43:27 pm
Choose Darwin and not macOS !
Title: Re: Compiling for OSX from Windows
Post by: Grahame Grieve on September 30, 2020, 12:31:19 am
oh. What's the difference?

thanks
Title: Re: Compiling for OSX from Windows
Post by: trev on September 30, 2020, 01:32:30 am
oh. What's the difference?

MacOS (more correctly "Mac OS", there never was a "MacOS") = the Classic Mac Operating System developed for the Macintosh family of personal computers by Apple from 1984 to 2001, starting with System 1 and ending with Mac OS 9.

Darwin = the open source BSD UNIX core set of components on which macOS (originally marketed as Mac OS X and then OS X) runs.

Title: Re: Compiling for OSX from Windows
Post by: Grahame Grieve on September 30, 2020, 02:07:26 am
well, that's obscure. So now I have another problem, though I don't know whether this is anything to do with FPCUpdeluxe:

32 bit darwin won't install in FPCdeluxe:

C:/tools/lazarus/fpc/bin/x86_64-win64/ppcross386.exe -Ur -dFPC_USE_LIBC -Tdarwin -Pi386 -XPx86_64-apple-darwin15- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../i386 -Fi../unix -Fi../bsd -Fi../bsd/i386 -Fi../darwin/i386 -FDC:\tools\lazarus\cross\bin\x86-darwin -FE. -FUC:/tools/lazarus/fpcsrc/rtl/units/i386-darwin -vw-n-h-l-d-u-t-p-c- -dFPC_SOFT_FPUX80 -di386 -dRELEASE -WM10.8 -XPx86_64-apple-darwin15- -Xd -FlC:\tools\lazarus\cross\lib\x86-darwin\MacOSX10.11.sdk\usr\lib -FlC:\tools\lazarus\cross\lib\x86-darwin\MacOSX10.11.sdk\usr\lib\system  -Us -Sg ../bsd/system.pp
C:\tools\lazarus\fpcsrc\rtl\units\i386-darwin\system.s:10:2: error: instruction requires: Not 64-bit mode
        pushfl
        ^

then many 100s more.

64 bit won't compile in Lazarus:

CarbonBars.pas:

{$IFNDEF cpui386}
{$ERROR only cpu i386 is supported}
{$ENDIF}
             
Title: Re: Compiling for OSX from Windows
Post by: trev on September 30, 2020, 04:48:36 am
You cannot run or compile 32 bit applications on Catalina or later because 32 bit support has (mostly - there are some Carbon bits left) been removed. Mac computers have been 64 bit capable since 2007.

This:

Quote
CarbonBars.pas:

{$IFNDEF cpui386}
{$ERROR only cpu i386 is supported}
{$ENDIF}

suggests that you are trying to compile for 32 bit (i386) instead of 64 bit (x86_64).

Go to Project > Project Options > Compiler Options > Config and Target and setup as follows:

Target OS: Darwin
Target CPU Family: x86_64
Target Processor (Default)
Current LCL widgetset: "Cocoa"

Cocoa is 64 bit; Carbon is 32 bit.
Title: Re: Compiling for OSX from Windows
Post by: DonAlfredo on September 30, 2020, 07:12:01 am
@trev
All correct ! Thanks.

Quote
error: instruction requires: Not 64-bit mode
As stated in a previous post, I have switched back to FPC stable (3.2) due to this error. FPC stable will compile for Darwin i386.
Title: Re: Compiling for OSX from Windows
Post by: PascalDragon on September 30, 2020, 09:51:21 am
oh. What's the difference?

MacOS (more correctly "Mac OS", there never was a "MacOS") = the Classic Mac Operating System developed for the Macintosh family of personal computers by Apple from 1984 to 2001, starting with System 1 and ending with Mac OS 9.

Darwin = the open source BSD UNIX core set of components on which macOS (originally marketed as Mac OS X and then OS X) runs.

Please note that in FPC trunk the Mac OS Classic target has been renamed to MacOSClassic so that in the future we might add a specific MacOS target that would allow for differences between pure Darwin and full MacOS (e.g. user/global settings). This also lead to the introduction of an explicit iOS target, which blocked aarch64-darwin.
Title: Re: Compiling for OSX from Windows
Post by: Grahame Grieve on September 30, 2020, 02:46:33 pm
ok, cocoa vs carbon was my issue - compiling for fine now, great.

Thanks for all the help, really appreciate it.
TinyPortal © 2005-2018