Thread overview
Cross-compiling dub projects with LDC
Aug 25, 2019
kinke
Aug 25, 2019
Dennis
Aug 27, 2019
Oleg B
Aug 27, 2019
Oleg B
August 25, 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
August 25, 2019
On Sunday, 25 August 2019 at 21:16:22 UTC, kinke wrote:
> as many of you probably know, LDC can be used for cross-compilation, and setting that up isn't rocket-science. [1]

I actually presumed it would be pretty complicated, so thanks for letting me know this is a thing!
Since I work on both Windows and Linux I can natively compile and test my D projects for both, but this could still come in handy.
August 27, 2019
On Sunday, 25 August 2019 at 21:16:22 UTC, kinke wrote:

> 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.

Is this supports only in dub-1.17.0-beta.2 and it's not include to ldc2-1.17.0?
August 27, 2019
> Is this supports only in dub-1.17.0-beta.2 and it's not include to ldc2-1.17.0?

It feature only in dub-master by now

But it's cool works) Thanks!