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?
The VCRuntime contains code required to initialize and terminate a C/C++ executable.
In Visual Studio 2022, the redistributable files are in the %VCINSTALLDIR%Redist\MSVC\v143 folder. In the latest version of Visual Studio 2019, you'll find the redistributable files in the %VCINSTALLDIR%Redist\MSVC\v142 folder.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With