www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How to make fat binary on windows (WinAPI + LDC)

reply Suliman <evermind live.ru> writes:
     Retelling from the grid of my torments:
     Problem Summary:
     	1	ABI Incompatibility: LDC on Windows compiles D runtime 
only for MSVC ABI, while the GUI project uses MinGW GCC with a 
different ABI (different symbol naming and calling conventions).
     	2	D runtime not embedded: When building a static library via 
ldc2 -lib, D runtime symbols (_d_allocclass etc.) remain 
unresolved references, not included in the .lib file.
     	3	MinGW runtime doesn’t build: Attempt to rebuild D runtime 
for MinGW failed—LDC sources require patches for MinGW target 
support (error “Unsupported platform”).
     	4	Linking problem: MinGW linker (ld) cannot properly handle 
MSVC .lib files, and MSVC linker requires compiling C code with 
/TC flag, conflicting with existing code.
     	5	Fundamental limitation: On Windows, no simple way to 
statically link C code (MinGW) with D library (LDC/MSVC) due to 
different toolchains—must either build everything via MSVC or use 
DLL.

This is resume of my attempts to build. DLL works fine but I want 
fat binary
Nov 08
parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On Saturday, 8 November 2025 at 12:00:33 UTC, Suliman wrote:
     Retelling from the grid of my torments:
[snip]
 This is resume of my attempts to build. DLL works fine but I 
 want fat binary
By fat you mean statically linked executable? Then indeed the problem of handling multiple runtimes is a problem MinGW essentially has its own libc and mixing that with MSVC’s libc is not possible. To solve that your code most likely has to pick one of two and suffer through porting the code that uses the other. I thought fat binary was meant to include multiple architectures like on MacOS where you could bundle ARM64 and Intel versions in one binary. — Dmitry Olshansky
Nov 08
parent reply Suliman <evermind live.ru> writes:
 To solve that your code most likely has to pick one of two and 
 suffer through porting the code that uses the other.
Do you mean that I should rewrite all to one language? Yes, I talk about statically linked binary
Nov 08
parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On Sunday, 9 November 2025 at 05:32:20 UTC, Suliman wrote:
 To solve that your code most likely has to pick one of two and 
 suffer through porting the code that uses the other.
Do you mean that I should rewrite all to one language?
Not language but runtime. So if some part is in say C++ you’d need to recompile it with MSVC not MinGW. Alternatively you’d need to port D to MinGW runtime, but that seems like more work.
 Yes, I talk about statically linked binary
— Dmitry Olshansky
Nov 09