Correct way to distribute VC++ runtime files
Asked Answered
L

3

7

I have an MFC application which I am trying to package for deployment. It seems to depend on the files 'msvcr90.dll', 'msvcp90.dll' and 'mfc90.dll'. What is the correct way to distribute these files?

I can't use merge modules as my installer doesn't support them. I know I can run VCRedist_x86.exe, but I don't want to do this for various reasons.

As far as I can see my only alternative is to install the files as Private Side-by-Side assemblies. Is this correct?

According to http://msdn.microsoft.com/en-us/library/ms235317(VS.80).aspx the correct way to install a private assembly is to copy the 'Microsoft.VC90.CRT' and 'Microsoft.VC90.MFC' folders to the same folder as the executable. Is this the correct way to solve the problem? It works, but it seems a bit 1990s to copy system files in this manner. Can anyone show me an example of another application (or at least a demo project) that does this?

Finally, when do I need to worry about distributing a .manifest file for my application? Am I supposed to explicitly install the XML file, or is it embedded in my executable somehow?

Loggerhead answered 3/2, 2010 at 13:25 Comment(3)
FWIW I asked a similar question about shipping the CRT DLLs. #2131593Glorify
Welcome to DLL Hell, chapter 3. *(The first two chapters discuss file location issues and version issues.)Superfluous
Notice that your linked article no longer recommends copying any DLLs and instead redirects to the vcredist download page.Hannus
A
1

Normally I would say that you should install the required redistributable on the target machine as it is the "clean way". But you can also do it the 90s style. It strongly depends which CRT/MFC lib you are using to build the application. This can be inspected within the manifest file. You can also force the application to bind with a specified lib. Without any define VS2008 normally binds the 9.0.21022.8, with

#define _BIND_TO_CURRENT_VCLIBS_VERSION 1

the most recent libs are taken. You can also bind with a specified version:

#define _CRT_ASSEMBLY_VERSION "9.0.30729.1"

and/or

#define _MFC_ASSEMBLY_VERSION "9.0.30729.1"

So if you want to do it the 90s style, copy the files from C:\Windows\Winsxs\ and take the DLLs from that folder you binded with, e.g. from amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_99b61f5e8371c1d4 if you use CRT for an x64 application or the equivalent x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_99b61f5e8371c1d for the x86 version of CRT.

Ariew answered 3/2, 2010 at 13:43 Comment(0)
G
1

You could also consider statically linking with both MFC and the CRT, then you only need to ship your EXE files. There are pros and cons to this though.

Glorify answered 3/2, 2010 at 14:25 Comment(1)
That's true, but Microsoft discourages static linking.Memphis
E
1

I would say that is enough to put these dlls along with your exe, because the current path is where they are firstly looked for.

Of course, you should strive to install the redistributable as that's the safer way to go.

Elevation answered 3/2, 2010 at 16:16 Comment(2)
Using the redistributables is the current recommendation by Microsoft.Memphis
This is the correct answer. Microsoft recommends either installing the redistributable or install the dlls alongside the executable. To quote: "To deploy redistributable Visual C++ files, you can use the Visual C++ Redistributable Packages that are included in Visual Studio or use redistributable merge modules, or you can directly install redistributable Visual C++ DLLs in the application local folder, which is the folder that contains the executable application file."Dithyramb

© 2022 - 2024 — McMap. All rights reserved.