Microsoft Visual C ++ program deployment Method

Source: Internet
Author: User

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.

Copy codeThe Code is as follows: <? 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 level = '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

Copy codeThe Code is as follows: <? 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 = "Hangzhou"> <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 = "Hangzhou"> <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 = "Hangzhou"> <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 ).

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.