Cross-compiling dub projects with LDC

kinke noone at nowhere.com
Sun Aug 25 21:16:22 UTC 2019


Hi guys,

as many of you probably know, LDC can be used for 
cross-compilation, and setting that up isn't rocket-science. [1]

Cross-compiling a dub project is now [2] possible too (in dub 
master, so you'll have to build it manually for now if 
interested). As cross-compiling to Windows is the simplest 
scenario (no external toolchain required), the few required steps 
for a vibe.d hello-world are:

* Set up your LDC installation for cross-compilation to Win64, 
see [1].
   It's a matter of
   1) downloading the LDC Win64 package,
   2) extracting and renaming the `lib` directory, and
   3) extending your etc/ldc2.conf by a Win64 section.
* Create a dummy project and cross-compile it to Win64 by 
specifying
   the appropriate target triple (LDC `-mtriple`) as `--arch`:
     dub init cctest -t vibe.d
     cd cctest
     dub build --arch=x86_64-pc-windows-msvc [--compiler=ldc2]

The resulting cctest.exe (incl. 2 DLLs) can be copied to a Win64 
box and then runs fine, as long as a Visual C++ runtime ≥ 2015 is 
installed. Tested on a Linux host, but should work on any host.

[1] https://wiki.dlang.org/Cross-compiling_with_LDC
[2] https://github.com/dlang/dub/pull/1755


More information about the Digitalmars-d-announce mailing list