Thread overview
How to link a msvcr120.dll in an inverse recursive way after a Windows .exe binary deployment
Sep 04, 2022
BoQsc
Sep 04, 2022
rikki cattermole
Sep 04, 2022
ShadoLight
Sep 05, 2022
BoQsc
Sep 06, 2022
ShadoLight
Sep 06, 2022
Mike Parker
Sep 06, 2022
ShadoLight
September 04, 2022

HelloWorld

Folder structure

.\msvcr120.dll
.\folder1\HelloWorld.exe
.\folder2\HelloWorld.exe

Basic binaries produced by DMD.exe compiler require Microsoft Compiler Runtime DLL

As you might know that a basic D Language example HelloWorld.exe requires msvcr120.dll to work.

Linking inverse recursively?

To not include msvcr120.dll into every .exe executable's .\folder\ and to not marginally increase the overall size of the project: I'd like to link every .\folder\.exe binary to the .\msvcr120.dll dynamic library.

Notice
Launching the .exe binary with external script to change the path variable is not a solution.
I'd like the .exe binary to "know" and try to search for .\msvcr120.dll by itself after clicking it to launch.

September 05, 2022
I've been reading up fairly recently on RPATH for *nix which does what you want. Unfortunately as far as I've found there is no way to do this on Windows without an extra executable.
September 04, 2022

On Sunday, 4 September 2022 at 15:16:47 UTC, BoQsc wrote:

>

Folder structure

.\msvcr120.dll
.\folder1\HelloWorld.exe
.\folder2\HelloWorld.exe

You don't need to do this. msvcr120.dll is already shipped with the DMD compiler at [DMD-install-folder]\windows\bin64\msvcr120.dll. (It is also in [DMD-install-folder]\windows\bin). You can access it directly from there.

When you run your EXE... the OS looks for the DLL in the same folder of the EXE- if it cannot find it it looks in the folders specified in your PATH.

You can test if this is the case by executing 'where msvcr120.dll' at a DOS console command prompt. If the DLL is reachable in any folder in your PATH environment variable these specific path(s) will be displayed. In this case you don't need to do anything - the EXE should be able to run and load the DLL.

The fact that you get this error indicate this is not the case. You can do 1 of the following 2 things:

  • add your DMD bin64 (or bin) path to the PATH environment variable.
    --or--
  • Copy the DLL to C:\Windows\System32\ - that will for sure already be in your PATH so you don't need to modify your PATH environment variable.
September 05, 2022

On Sunday, 4 September 2022 at 22:05:24 UTC, ShadoLight wrote:

>

On Sunday, 4 September 2022 at 15:16:47 UTC, BoQsc wrote:

>

Folder structure

.\msvcr120.dll
.\folder1\HelloWorld.exe
.\folder2\HelloWorld.exe

You don't need to do this. msvcr120.dll is already shipped with the DMD compiler at [DMD-install-folder]\windows\bin64\msvcr120.dll. (It is also in [DMD-install-folder]\windows\bin). You can access it directly from there.

The problem is, D Language Compiler is not included along the Windows Operating System.
Neither msvcr120.dll is included along the Windows Operating System.
You have to download it. No other way.

How can you download it, if your .exe binary that has the functionality to download it, cannot even be started due to msvcr120.dll not existing on the operating system.

You can try to use pre-existing Command Line Utilities like bitsadmin (Windows 7), curl (Windows 10), but really how can you interact with them from within D Language Binary if it can't even launch.

You can try to write a batch script for all that.

I really do not want to write batch scripts for the rest of my life,
that's why I'm here in the D Language Forum.

>

Copy the DLL to C:\Windows\System32\

It required administrator privilegies and this is only a HelloWorld example
of the D language deployed on computers, where the D language is yet to be installed.

September 06, 2022

On Monday, 5 September 2022 at 07:02:53 UTC, BoQsc wrote:

>

The problem is, D Language Compiler is not included along the Windows Operating System.

No compiler is included natively with the Windows OS. Not even Microsoft's.

>

Neither msvcr120.dll is included along the Windows Operating System.
You have to download it. No other way.

Or... you download the DMD installer which conveniently include it for you.

>

How can you download it, if your .exe binary that has the functionality to download it, cannot even be started due to msvcr120.dll not existing on the operating system.

I don't understand this. You need DMD to build your EXE. I suppose you have this since your question is specifically about DMD. If that is the case you have the DLL you need.

> >

Copy the DLL to C:\Windows\System32\

It required administrator privilegies and this is only a HelloWorld example
of the D language deployed on computers, where the D language is yet to be installed.

True. In that case just distribute the DLL (taken from the DMD bin folder) alongside the HelloWorld EXE so that both reside in the same folder on the target computer. If you don't have administrative priveleges you cannot modify the PATH on the target computer either, so this is the only way. That is anyway quite standard under Windows - if you search for msvcr*.dll on any Windows machine you'll find lots of copies co-located with the EXEs that use them (using the version that came with the specific version of Visual Studio they were using to build the EXE - for example msvcr90.dll). These DLLs are simply the Visual Studio C/C++ Runtime distributed with Visual Studio.

September 06, 2022

On Tuesday, 6 September 2022 at 04:36:55 UTC, ShadoLight wrote:

>

True. In that case just distribute the DLL (taken from the DMD bin folder) alongside the HelloWorld EXE so that both reside in the same folder on the target computer.

The proper way to do this is to ship the correct version of the Visual C++ redistributable installer and run it as part of the application install process:

https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

September 06, 2022

On Tuesday, 6 September 2022 at 04:59:49 UTC, Mike Parker wrote:

>

On Tuesday, 6 September 2022 at 04:36:55 UTC, ShadoLight wrote:

>

True. In that case just distribute the DLL (taken from the DMD bin folder) alongside the HelloWorld EXE so that both reside in the same folder on the target computer.

The proper way to do this is to ship the correct version of the Visual C++ redistributable installer and run it as part of the application install process:

https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

Sure. But the OP seems to indicate that he doesn't have administrative privileges on the machines they wish to distribute and test his HelloWorld example.

I don't know if you can run an installer without administrative privileges - at least not if you want to write to Program Files / Program Files (x86), modify the Registry, environment variables, etc. I'm not even sure if you can create a folder on Windows 10 without administrative rights without resorting to some tricks. I've never required that - and would think that the IT department (that handles installs and updates on their organization's computers) should have an admin account on all of them.

My take was that he can simply copy the EXE and associated DLLs to an existing folder on the target machine if he just want to test it running on a non-developer machine.

Making an installer is another mini-project by itself .. not sure if he wants to be burdened with such a step simply to resolve his DMD issue.

But your redistributable installer link is indeed the proper way.