Linux -> Windows crosscompiler

Joakim via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Mon May 15 10:37:30 PDT 2017


On Monday, 15 May 2017 at 09:27:36 UTC, Marvin G├╝lker wrote:
> Hi everyone,
>
> I am mainly a Linux developer and find working on Windows 
> rather complicated. My most recent try confirmed that; I wanted 
> to write a D application using GraphicsMagick's C interface -- 
> now I have a mixture of compilers on my Windows machine (MinGW 
> GCC, Msys2 GCC, MSVC, LDC, DMD) and I still get linking errors.

Are you mixing object files produced by different D compilers?  
That won't work, you need to compile all your D code with a 
single D compiler.

> That only for the context. Since I previously had good 
> experience in
> using a Linux -> Windows crosscompiler for regular C/C++ 
> (MXE[1]) I thought
> it could be possible to have something similar for D. Until now 
> I have
> been using dmd, but Internet research told me dmd cannot be 
> built as a
> crosscompiler. GDC appears to be a one-man show and is still 
> pending
> upstream GCC approval, so I decided to go with LDC.

It can be done with dmd, but it would require some work on the 
compiler itself.

> Thus, is it possible to build an LDC crosscompiler that is 
> hosted on x86_64 Linux and targets i686/x86_64 Windows? If so, 
> how? I didn't find any information on the topic, people 
> appeareantly only ever want to target ARM (cell phones?), which 
> is not what I am interested in.

Of course, by default ldc is a cross-compiler for all other 
platforms it officially supports.  You simply need to pass the 
right llvm triple to ldc, similar to how it's done for the ARM 
cross-compiler.

The bigger issue is getting the cross-compiled stdlib and a 
cross-linker, that will link for Windows but run on linux.  You 
can probably just take the pre-built stdlib from the ldc for 
Windows package, but you're on your own for finding a 
cross-linker.  Maybe lld would work?

http://lld.llvm.org


More information about the digitalmars-d-ldc mailing list