Microsoft Visual C ++ program deployment

Source: Internet
Author: User
Microsoft Visual C ++ Program Deployment

A program compiled by Microsoft Visual C ++ dynamically links to the C Runtime (/MD or/MDD). It must be bundled with a copy of the C Runtime DLL (usually called msvcrt. DLL or msvcrxx. DLL, where xx represents the Visual C ++ version ).

1. programs compiled with Microsoft Visual C ++ 6.0, or published on Windows 2000/NT/ME/98
Simply copy the msvcrxx. dll file to the application directory or system32 directory.

2. programs compiled with Visual Studio 2005 and later are released on Windows XP and later systems.
To reduce DLL-caused configuration problems (DLL hell), C and C ++ are implemented by parallel (side-by-side) Assembly during runtime, simply by copying msvcrxx. DLL is not enough to run programs normally in a non-development environment. You must use a manifest to load the crt dll. If this list is not found when the C Runtime Library is loaded, the r6034 exception is thrown. This is why CRT DLLs is currently in the winsxs (Windows side-by-side) instead of the System32 directory.

Both the EXE and DLL files have a manifest file, which describes the dependency. After being compiled with Visual Studio 2005, a manifest file with the same name as the executable file is automatically generated, for example:
App.exe // Executable File
App.exe. manifest // DLL dependent File
Generally, the manifest files of EXE and DLL are embedded into the EXE and DLL files, and external manifest files can be deleted. For example:
Mt.exe/nologo/manifest ". \ app.exe. manifest"/outputresource: ". \ app.exe"; 1
In the EXE file, the last value is 1. In the DLL file, the value is 2.
The manifest file is not embedded in the DLL file of Microsoft Visual C ++ Runtime Library. Therefore, an external manifest file is required. The manifest file of Visual Studio 2005 is called Microsoft. vc80.crt. manifest, manifest of Visual Studio 2008 is Microsoft. vc90.crt. manifest, So Microsoft. vc80.crt. copy the four files manifest, msvcr80.dll, msvcp80.dll, and msvcm80.dll to the application directory. For example
C: \ test \ app.exe
C: \ test \ msvcr80.dll
C: \ test \ msvcp80.dll
C: \ test \ msvcm80.dll
C: \ test \ microsoft. vc80.crt. manifest
Or use Microsoft official recommendations, such:
WINXP or above
C: \ test \ app.exe
C: \ test \ microsoft. vc80.crt \ microsoft. vc80.crt. manifest
C: \ test \ microsoft. vc80.crt \ msvcr80.dll
C: \ test \ microsoft. vc80.crt \ msvcp80.dll
C: \ test \ microsoft. vc80.crt \ msvcm80.dll
Below Win2k
C: \ test \ app.exe
C: \ test \ msvcr80.dll
C: \ test \ msvcp80.dll
C: \ test \ msvcm80.dll
If the above method still cannot be executed, it means that Microsoft Visual C ++ has multiple versions of DLL in the system. The program uses a different version from the released Microsoft Visual C ++ DLL, for example:
The app. manifest file requires Microsoft. vc90.crt DLL and the version is 9.0.21022.8.

< ? XML Version = '1. 0' Encoding = 'Utf-8' Standalone = 'Yes' ? >
< Assembly xmlns = 'Urn: Schemas-Microsoft-com: ASM. v1' Manifestversion = '1. 0' >
< Trustinfo xmlns = "Urn: Schemas-Microsoft-com: ASM. V3" >
< Security >
< Requestedprivileges >
< Requestedexecutionlevel = 'Asinvoker' UIAccess = 'False' / >
< / Requestedprivileges >
< / Security >
< / Trustinfo >
< Dependency >
< Dependentassembly >
< Assemblyidentity type = 'Win32' Name = 'Microsoft. vc90.crt' Version = '9. 0.21022.8' Processorarchitecture = 'X86' Publickeytoken = '1fc8b3b9a1e18e3b' / >
< / Dependentassembly >
< / Dependency >
< Dependency >
< Dependentassembly >
< Assemblyidentity type = 'Win32' Name = 'Microsoft. Windows. Common-controls' Version = '6. 0.0.0' Processorarchitecture = 'X86' Publickeytoken = '6595b64144ccf1df' Language = '*' / >
< / Dependentassembly>
< / Dependency >
< / Assembly >

Microsoft. vc90.crt. manifest file, indicating that it is Microsoft. vc90.crt, but the version is 9.0.30729.1

< ? XML Version = "1.0" Encoding = UTF-8" Standalone = "Yes" ? >
< Assembly xmlns = "Urn: Schemas-Microsoft-com: ASM. V1" Manifestversion = "1.0" >
< Noinheritable> < / Noinheritable >
< Assemblyidentity type = "Win32" Name = "Microsoft. vc90.crt" Version = "9.0.30729.1" Processorarchitecture = "X86" Publickeytoken = "1fc8b3b9a1e18e3b" > < / Assemblyidentity >
< File Name = "Msvcr90.dll" Hashalg = "Sha1" Hash = "9785b1c493deb5b2134dc4aef3719cee207001bc" > < Asmv2: Hash xmlns: asmv2 = "Urn: Schemas-Microsoft-com: ASM. V2" Xmlns: dsig = Http://www.w3.org/2000/09/xmldsig" > < Dsig: Transforms > < Dsig: Transform Algorithm = "Urn: Schemas-Microsoft-com: hashtransforms. Identity" > < / Dsig: Transform > < / Dsig: Transforms > < Dsig: digestmethod Algorithm = Http://www.w3.org/2000/09/xmldsig#sha1" > < / Dsig: digestmethod > < Dsig: digestvalue > Vf5ecuahpv7enuf + / Uixmpizpvs = < / Dsig: digestvalue > < / Asmv2: Hash > < / File > < File Name = "Msvcp90.dll" Hashalg = "Sha1" Hash = "0f6bbf7fe4fb3fca2cb5b542eca1a1cad051f01c" > < Asmv2: Hash xmlns: asmv2 = "Urn: Schemas-Microsoft-com: ASM. V2" Xmlns: dsig= Http://www.w3.org/2000/09/xmldsig" > < Dsig: Transforms > < Dsig: Transform Algorithm = "Urn: Schemas-Microsoft-com: hashtransforms. Identity" > < / Dsig: Transform > < / Dsig: Transforms > < Dsig: digestmethod Algorithm = Http://www.w3.org/2000/09/xmldsig#sha1" > < / Dsig: digestmethod > < Dsig: digestvalue > 3wg + Stvmq2uhx7ponakl2w4ddmy = < / Dsig: digestvalue > < / Asmv2: Hash > < / File > < File Name = "Msvcm90.dll" Hashalg = "Sha1" Hash = "7f3290ab2b7444c2b4a9b1fedfdb16466d7a21bb" > < Asmv2: Hash xmlns: asmv2 = "Urn: Schemas-Microsoft-com: ASM. V2" Xmlns: dsig = Http://www.w3.org/2000/09/xmldsig" > < Dsig: Transforms > < Dsig: Transform Algorithm = "Urn: Schemas-Microsoft-com: hashtransforms. Identity" > < / Dsig: Transform > < / Dsig: Transforms > < Dsig: digestmethod Algorithm = Http://www.w3.org/2000/09/xmldsig#sha1" > < / Dsig: digestmethod > < Dsig: digestvalue > / Yfrn7uqenzdmeomhxtgdrmioba = < / Dsig: digestvalue > < / Asmv2: Hash > < / File>
< / Assembly >

Because the two versions are inconsistent, the program cannot run. The solution is to release the Microsoft. vc90.crt file of 9.0.21022.8 as required by the program.

3. Another simple method is to install visual c ++ 2008 redistributable package (x86) or (x64) on the machine to be deployed ).
Microsoft Visual C ++ 2005 SP1 download:
Http://download.microsoft.com/download/7/9/8/798325b7-8993-4ef9-9148-8db9ff4187fc/vcredist_x86.exe

Note:
Use dependency walker(depends.exe) to open the EXE to be released and find the DLL to be depended on in the system from the list in the upper left corner.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.