Thread overview
Minimal environment for linking Win32 windowed 64bit exes usind LDC2
Jul 18
realhet
Jul 18
Kagamin
Jul 18
realhet
Jul 18
realhet
Jul 18
Luna
Jul 18
realhet
July 18

Hello,

What are the minimal environment to do generate win32 64bit windoswed exe's nowadays?

Can I do it with only these two?

  • LDC2 release
  • and a few static lib files extracted from the windows 10 sdk

Is it right?
Is there a way to avoid that 2 gigabytes of SDK somehow?
Is it possible to avoid even VC_redist with this minimal environment?

Thank You in advance!

July 18

ldc has libs in lib/mingw

July 18

On Friday, 18 July 2025 at 15:25:04 UTC, Kagamin wrote:

>

ldc has libs in lib/mingw

Please help me how to use it.

Currently I managed to compile a very simple example, after installing win10 sdk:
I was happy that I don't even need to pass
--m64
--line-internally
Because it was defaulted.
I only passed -L/subsystem:windowed

import core.sys.windows.windows;
import core.sys.windows.winuser;

extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    MessageBoxA(null, "Hello, Win32!", "D Language", MB_OK);
    return 0;
}

Compiled with:

ldc2 win32_app.d -L/subsystem:windows

Simple and effective.

But with a 40k project it fails at the very end with:
lld-link: error: could not open 'libcmt.lib': no such file or directory
lld-link: error: could not open 'LIBCMT.lib': no such file or directory
Error: linking with LLD failed

I also asked Deepseek, how to use that mingw and it said I need gcc.
But I have LDC2 with an internal linker.

What is this libcmt problem?
I only found the word libcmt in a 5 year old comment, that's not an actual pragma(lib) made by me.

July 18

On Friday, 18 July 2025 at 15:42:23 UTC, realhet wrote:

>

On Friday, 18 July 2025 at 15:25:04 UTC, Kagamin wrote:

>

ldc has libs in lib/mingw

Ok I was doing too much:

I uninstalled the whole sdk and it turned out It works miraculously just by itself:
ldc2 win32_app.d -L/subsystem:windows as simple of that, very cool!

And with the more complicated project, I think it also worked, but the error was just generated by static libraries I'm using:
libwebp.lib
turbojpeg-static.lib

Inside these binaries I found hundreds of this text: /DEFAULTLIB:"LIBCMT"

And the linker says this error as well:
lld-link: error: could not open 'libcmt.lib': no such file or directory
lld-link: error: could not open 'LIBCMT.lib': no such file or directory
Error: linking with LLD failed

There is no libcmt.lib on my HDD at all. There was ntuc_libcmt.lib in the windows SDK, but I uninstalled that so the mingW can be active.

(Btw, these are the stuff that is turning people backwards from systems programming and turn them right into a browser's comfortable console. But not me: I spend 1 or 2 days on this every year, lol. Even I hate this 1980s style command line hell, I know this worth the struggle. :D)

July 18

On Friday, 18 July 2025 at 16:50:07 UTC, realhet wrote:

>

On Friday, 18 July 2025 at 15:42:23 UTC, realhet wrote:

>

On Friday, 18 July 2025 at 15:25:04 UTC, Kagamin wrote:

>

ldc has libs in lib/mingw

Ok I was doing too much:

I uninstalled the whole sdk and it turned out It works miraculously just by itself:
ldc2 win32_app.d -L/subsystem:windows as simple of that, very cool!

And with the more complicated project, I think it also worked, but the error was just generated by static libraries I'm using:
libwebp.lib
turbojpeg-static.lib

Inside these binaries I found hundreds of this text: /DEFAULTLIB:"LIBCMT"

And the linker says this error as well:
lld-link: error: could not open 'libcmt.lib': no such file or directory
lld-link: error: could not open 'LIBCMT.lib': no such file or directory
Error: linking with LLD failed

There is no libcmt.lib on my HDD at all. There was ntuc_libcmt.lib in the windows SDK, but I uninstalled that so the mingW can be active.

(Btw, these are the stuff that is turning people backwards from systems programming and turn them right into a browser's comfortable console. But not me: I spend 1 or 2 days on this every year, lol. Even I hate this 1980s style command line hell, I know this worth the struggle. :D)

libcmt and co are a part of the Windows SDK. So you’d get those by installing Visual Studio C++ tools

July 18

On Friday, 18 July 2025 at 16:58:13 UTC, Luna wrote:

>

On Friday, 18 July 2025 at 16:50:07 UTC, realhet wrote:

>

On Friday, 18 July 2025 at 15:42:23 UTC, realhet wrote:

>

On Friday, 18 July 2025 at 15:25:04 UTC, Kagamin wrote:

>

ldc has libs in lib/mingw

libcmt and co are a part of the Windows SDK. So you’d get those by installing Visual Studio C++ tools

Yes, this worked, thx!

I installed build tools 2022 and windows 11 sdk, LDC2 automatically noticed it and switched to that libcmt. From that whopping 6GB it used 100KB. So the simplest windows application grow from 6KB to 105KB by doing the static linking.

After that my bigger test with the external static libs was also successful.

The only LDC2 parameter is us now is --link-internally because that linker is really fast, I like it. Otherwise it is automatic, I just need to install the right programs before.

Thank You!