ldc icon indicating copy to clipboard operation
ldc copied to clipboard

static Windows build

Open 89z opened this issue 1 year ago • 9 comments

Using this program:

import stdio = std.stdio;

void main() {
   stdio.writeln("hello world");
}

and this command:

ldc2 app.d

I do not get a static build. Namely, the file vcruntime140.dll is required. So I tried this:

ldc2 -static app.d

same result. It seems LDC includes the static library:

    Directory: D:\ldc2\lib\mingw

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2022-07-20  1:10 PM          32542 vcruntime140.lib

so it would appear it should be possible to do what I am trying to do.

89z avatar Aug 27 '22 00:08 89z

You'll need an MSVC++ installation for that; then linking the MSVCRT statically is the default behavior (except for DLLs). See https://github.com/ldc-developers/ldc/blob/master/packaging/README.txt#L10-L23.

kinke avatar Aug 27 '22 09:08 kinke

I dont understand. If LDC has its own linker, and also includes the static library needed, why cant LDC just link the static library?

89z avatar Aug 27 '22 13:08 89z

It's a custom tiny CRT skeleton, based on the MSVC DLLs. If you really want to know more details, see https://github.com/ldc-developers/mingw-w64-libs (where the vcruntime140.lib is from).

kinke avatar Aug 27 '22 17:08 kinke

OK fair enough, but it seems you could at least make the process simpler, for people who are in this position. For example, I dont see any links for people who want to download the Redistributable. Including that in the Readme or similar would be helpful to Windows users:

https://docs.microsoft.com/cpp/windows/latest-supported-vc-redist

89z avatar Aug 27 '22 17:08 89z

PRs are welcome. - Not sure what position you are talking about - I thought you wanted to link statically, that requires an VS/Build tools installation as mentioned in the readme. The redistributable only allows running the built stuff linked without VS (and AFAIK, comes with every non-ancient Windows).

kinke avatar Aug 27 '22 17:08 kinke

PRs are welcome.

done

Not sure what position you are talking about - I thought you wanted to link statically

I do

that requires an VS/Build tools installation as mentioned in the readme.

right. Hopefully you understand, that Visual Studio is a giant bloated dependency. So given that, I would rather just deal with the DLL requirement.

and AFAIK, comes with every non-ancient Windows

I am running Windows 10, and it is not preinstalled. I checked the C:\Windows\System32 folder. If its in another folder, I can check that, but I dont know where else it would be.

89z avatar Aug 27 '22 17:08 89z

I am running Windows 10, and it is not preinstalled.

Oh okay, thx - then it's just the UCRT OS component that is installed, but not the VC++ 2015+ runtime itself. - Thx for the PR.

kinke avatar Aug 27 '22 17:08 kinke

Can you change LDC such that, the built programs require UCRT instead of VC++ 2015+ runtime?

89z avatar Aug 27 '22 18:08 89z

Nope, it's e.g. required for exception handling (it's MSVC++ compatible).

kinke avatar Aug 27 '22 18:08 kinke