Possible to cross-compile from Linux to OSX?

Jacob Carlborg doob at me.com
Tue Feb 4 19:47:27 UTC 2020


On 2020-02-04 20:30, H. S. Teoh wrote:
> So far, cross-compiling from Linux to Windows has been awesome, thanks
> to LDC2's awesome cross-compiling capabilities. All I needed to do was
> to download the Windows ldc2 release, edit ldc2.conf to point to it,
> then compile with -mtriple=x86_64-windows-msvc, and it magically all
> works.
> 
> However, I'm having a tougher time cross-compiling to OSX... downloaded
> the ldc2 osx release, setup ldc2.conf, and compile with
> -mtriple=x86_64-apple-darwin, but it appears to be trying to invoke my
> local Linux linker, which chokes on the OSX object file format and dies
> horribly. :-P  I'm guessing I need to somehow install an OSX toolchain
> for this to work?

Here's a Dockerfile that can cross-compile to macOS [1]. You might want 
to update to a newer version of LDC. You can do that when building the 
Docker image using the `--build-arg` flag.

Note, the SDK is pulled from someones Dropbox account (in the base image 
multiarch/crossbuild).

[1] 
https://github.com/jacob-carlborg/docker-ldc-darwin/blob/master/Dockerfile

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list