Having trouble cross compiling with LDC

Joakim dlang at joakim.fea.st
Sun Dec 9 09:14:42 UTC 2018

On Saturday, 8 December 2018 at 22:16:32 UTC, o wrote:
> I have heard that LDC has great support for cross compilation, 
> but I can't figure out how to use it.
> I have a linux x64 host, and I am looking for a definitive step 
> by step guide to setting up LDC to cross compile targeting 
> windows x64, macosx, and linux arm64(raspberry pi).

They can be a bit hard to find, but they're out there.

Windows - 

Mac is tougher because it requires their proprietary SDK, but 
Jacob has put up a docker with it - 

Raspberry Pi - 

> From what I understand, the basic steps are as follows (but I 
> don't know how to actually go about doing them):
> 1. Use ldc-build-runtime to compile phobos library binaries for 
> the target OS/Arch.

There's a wiki page on this:


We should link it from the help text for ldc-build-runtime.

> 2. Run LDC, and tell it where to find the phobos binaries from 
> step 1, and tell it to use lld as a linker.
> 3. LDC outputs an executable that can run on the target 
> platform.

Yes, see the Android examples on its wiki page:


You don't have to use lld, we support other common linkers. Of 
course, you'll need those linkers built to cross-link for your 
target, but if you're using an existing C/C++ cross-compilation 
toolkit and integrating it with ldc as shown on the wiki, there 
should be a cross-linker available.

The advantage of lld is that it has good support for many 
platforms built in, the disadvantage is that it is still being 
developed and may producing crashing binaries on occasion.

> But, how do I actually go about doing these steps? How do I use 
> ldc-build-runtime? How do I tell LDC to use the cross-compiled 
> phobos/runtime instead of the default one?

See the instructions and examples above and ask questions if you 
can't figure out how to extend them for your situation. We can 
and do plan to streamline the cross-compilation process for 
common targets, but we cannot make available copyrighted C 
runtimes or anticipate every niche target out there.

More information about the Digitalmars-d mailing list