原创内容,转载请注明原文网址:http://homeqin.cn/a/wenzhangboke/jishutiandi/2019/0715/576.html
	        VC2005和VC2008编译出来的程序放到别人的电脑上为什么有可能无法运行呢?
	        这个问题常州手游开发无数人在问,但是很遗憾,没有人给出完整的解释和完美的解决方案。其实我也只有一台电脑,而且装了VC了,这个问题必须要台没有装这类软件的电脑才容易去分析。感谢那些为了测试我小程序的朋友,是你们一次次在如此恶劣的网络速度下收取我一次次修改的dll包和部署文件,才让这个问题的完美解决方案浮出水面。这里就把我的经验给大家分享吧。
	1:Microsoft Visual C++ 2008 Express Edition可以发布软件吗?
	        能!
	        很多人说,因为是Express版,不是Studio,所以只是用来练习语言的,不能发布软件——错!
	        除了没有MFC和ATL,基本上跟 .net 版本是一样的。发布出来的,是完整的可执行文件。
	2:VC 2008 (2005) 发布出来的程序必须附带上他们特定的dll文件吗?
	        不一定。
	        如果目标系统是个经常升级的系统,微软已经为其打上了所需要的dll文件补丁了,不需要在软件包里面附加特定的dll文件。特别在Vista系统中,你更是不需要VC8和VC9的dll文件。但是在常州游戏开发培训一些老版本的系统中,这些文件就是必须的。
	3:VC2008和VC2005特定的dll文件是哪些?
	VC8: msvcm80.dll, msvcp80.dll, msvcr80.dll
	VC9: msvcm90.dll, msvcp90.dll, msvcr90.dll
	4:如何部署文件?
	首先,请选择release版本;在生成可执行文件(exe文件)的时候,会得到相应的部署文件(manifest文件)。
	比如,得到a.exe文件,就会同时生成a.exe.intermediate.manifest文件。请将这2个文件放在同一文件夹下。
	然后,你需要VC8和VC9的部署文件:Microsoft.VC80.CRT.manifest和Microsoft.VC90.CRT.manifest。
	请到你的VC安装目录下寻找,比如:
	C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT
	手机App外包我这里也把2个部署文件直接贴出来,没装的直接用就是了:
	Microsoft.VC80.CRT.manifest
	<?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.VC80.CRT" version="8.0.50727.762" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
	<file name="msvcr80.dll" /> <file name="msvcp80.dll" /> <file name="msvcm80.dll" />
	</assembly>
	Microsoft.VC90.CRT.manifest
	<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
	<!-- Copyright (c) Microsoft Corporation.  All rights reserved. -->
	<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
	    <noInheritable/>
	    <assemblyIdentity
	        type="win32"
	        name="Microsoft.VC90.CRT"
	        version="9.0.21022.8"
	        processorArchitecture="x86"
	        publicKeyToken="1fc8b3b9a1e18e3b"
	    />
	    <file name="msvcr90.dll" /> <file name="msvcp90.dll" /> <file name="msvcm90.dll" />
	</assembly>
	然后将VC8的3个dll以及这个manifest装到一个文件夹里,并将文件夹命名为Microsoft.VC80.CRT。
	同样将VC9的3个dll以及这个manifest装到一个文件夹里,并将文件夹命名为Microsoft.VC90.CRT。
	将这2个文件夹放到与exe文件(及其部署文件)所在目录下就OK了。
	至于为什么VC9编译的程序要用VC8的dll,大家可以看看App开发培训我例程部署文件:
	<?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.VC80.CRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
	    </dependentAssembly>
	  </dependency>
	</assembly>
	VC 2008生成出来就需要VC90和VC80的CRT,我们能有什么脾气呢……
	也就是说,还别管你exe文件多大,要保证正常运行,我们需要首先拷贝这8个文件……
	MinGW(gcc)编译的就没这些麻烦。所以,我现在都是用两个编译器编译两个exe以供发布了。
上篇:上一篇:windows多线程关键段 CriticalSection
下篇:下一篇:VS2010 MFC常用类:定时器Timer



