Linux -> Windows crosscompiler

Joakim via digitalmars-d-ldc digitalmars-d-ldc at
Tue May 16 01:06:10 PDT 2017

On Tuesday, 16 May 2017 at 07:40:59 UTC, Marvin G├╝lker wrote:
> On Mon, May 15, 2017 at 05:37:30PM +0000, Joakim via 
> digitalmars-d-ldc wrote:
>> 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.
> I'm sorry if I was unclear. No, I don't do that. I have, for 
> the attempts on native Windows, however tried mixing 
> MinGW/MSYS2 GCC object files for C code with LDC ones for D 
> code. And I have tried mixing MSVC object files with LDC ones 
> for D code. The latter worked, but GraphicsMagick fails to 
> compile with MSVC 2017, and MSVC 2015 is only crashing for me. 
> I also tried mixing MinGW/MSYS2 GCC object files for C code 
> with DMD object files for D code, but haven't yet gotten around 
> to trying it with MSVC C object files since MSVC has stopped 
> working for me meanwhile.

OK, sometimes mixing D compilers is the problem, so thought I'd 
mention it.

> As a non-Windows dev, this is a quite frustrating experience 
> for me. The most annoying thing is that whatever one does with 
> the MSVC setup installer, it takes really, really, really long. 
> It doesn't do anything under an hour. Why is it distributed as 
> an ISO file that I have to burn to a DVD first? That slows 
> things further down... Since a few weeks, I finally have an 
> acceptable Internet connection (was a max 16MBit aDSL line 
> before), so at least downloading this insane amount of data 
> went acceptably fast.

How fast is your connection now?  I've been using two connections 
between 2-8 Mbps until recently, so even 16 Mbps seems fast to 
me. :)

> I have concluded from that that D+C on Windows doesn't work for 
> me, mostly because MSVC doesn't.

Sounds like it is the C that is the problem. ;) An alternative to 
Visual Studio is to download a Windows SDK that included the 
compiler and linker, like the Windows 7.1 SDK that I used years 

I don't know if they still include the compiler/linker in later 
versions of the Windows SDK, maybe one of the newer ones would 
work too.

> I'm sorry if I am only complaining all the time. I'm an 
> open-source developer myself, so I know that users complain all 
> the time about this or that not fitting their exotic edgecase. 
> I would have to work on LDC to support MinGW if I wanted it to 
> be otherwise, but given that I have never worked on a compiler 
> this is going to be difficult (and does not fit my time 
> constraints).

I don't know that you'd have to work on the compiler itself, as 
ldc used to support MinGW at one point.  My guess is that you'd 
just have to update some MinGW stuff in druntime, but I haven't 
looked at it.

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

This is likely not so bad, you simply have to use -v to see the 
linker command ldc tries to invoke and replace it by manually 
running with lld instead, especially since it's only needed once 
for the final executable.

More information about the digitalmars-d-ldc mailing list