www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Cross-compiling dub projects with LDC

reply kinke <noone nowhere.com> writes:
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
Aug 25 2019
next sibling parent Dennis <dkorpel gmail.com> writes:
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.
Aug 25 2019
prev sibling parent reply Oleg B <code.viator gmail.com> writes:
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?
Aug 27 2019
parent Oleg B <code.viator gmail.com> writes:
 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!
Aug 27 2019