今天, 我们继续解决vs2005编译, link到msvcr80.dll, 但是找不到dll的问题.
可以先看一下之前的某篇文章: VC++ Redistributable Package 的作用 = =b
Redistributing Visual C++ Files
这篇实际上就是描述了要发布link到crt的时候, 应该怎么做, 以及会出现的问题, 这些在之前都提过.
Troubleshooting C/C++ Isolated Applications and Side-by-side Assemblies
告诉我们如下有用的信息:
1. Building Visual C++ projects without manifest generation is not supported. Any C/C++ program built in Visual C++ 2005 has to include a manifest describing its dependencies on Visual C++ libraries.
2. If the manifest is embedded inside the binary, ensure that the ID of RT_MANIFEST is correct for this type of the binary. For applications, ID should be equal to 1, for most DLLs ID should be equal to 2.
3. On Windows XP, if an external manifest is present in the application's local folder, the operating system loader uses this manifest instead of a manifest embedded inside the binary. On Windows Server 2003 and later versions of Windows, the opposite is true—the external manifest is ignored and the embedded manifest is used when present.
4. It is recommended that all DLLs have a manifest embedded inside the binary. External manifests are ignored when a DLL is loaded though a LoadLibrary call.
5. the CRT assembly can also be installed as a private side-by-side assembly in the application's local folder. If the operating system fails to find the CRT or any other assembly as a shared assembly, it starts looking for the assembly as a private assembly. It searches for private assemblies in the following order:
*) Check the application local folder for a manifest file with name <assemblyName>.manifest. In this example, the loader tries to find Microsoft.VC80.CRT.manifest in the same folder as appl.exe. If the manifest is found, the loader loads the CRT DLL from the application folder. If the CRT DLL is not found, load fails.
*) Try to open folder <assemblyName> in appl.exe's local folder and if it exists, load manifest file <assemblyName>.manifest from this folder. If the manifest is found, the loader loads the CRT DLL from <assemblyName> folder. If the CRT DLL is not found, load fails.
最后一个解决了我们的问题 !!
这里有一篇文章告诉我们, 怎么诊断SxS的error: Diagnose SideBySide failures in Windows XP/Windows Server 2003
这里有一个side-by-side assembly(SxS) 的概念. 首先是assembly, 程序集, 疑似.NET的概念啊.
A Windows side-by-side assembly is described by manifests. A side-by-side assembly contains a collection of resources—a group of DLLs, Windows classes, COM servers, type libraries, or interfaces—that are always provided to applications together. These are described in the assembly manifest.
SxS assembly解决的是一个dll versioning conflicts的问题, 方法是通过一个manifest文件.
然后是isolation applicaton的概念.
Isolated applications are self-describing applications installed with manifests. Isolated applications can use both private assemblies and shared assemblies.
好的, 越说越离谱了, 又牵涉到了private assembly和shared assemblies.
A private assembly is an assembly that is deployed with an application and is available for the exclusive use of that application. That is, other applications do not share the private assembly.
A shared assembly is an assembly available for use by multiple applications on the computer. On Windows Vista and Windows XP, side-by-side assemblies can be installed as shared assemblies. Shared side-by-side assemblies are not registered globally on the system, but they are globally available to applications that specify a dependence on the assembly in manifests.
是不是糊涂了.. 个么SxS assembly和private/shared assembly到底是个什么关系呢? SxS只是一种机制, 加一个manifest文件, 来避免dll的版本冲突. 而private/shared是具体的实现方式. 举个例子, vs2005的crt dll默认使用的方式就是shared SxS assembly, 而如果我们把vs2005的crt dll放到应用程序的当前目录下, 在建立一个manifest文件, 那么这就是private SxS assembly.
dll 版本冲突, 也叫做dll hell, 是个什么东西: The End of DLL Hell. 而且很久很久以前就有了相对于的解决方案: Implementing Side-by-Side Component Sharing in Applications (Expanded). 那如果不是SxS assembly, 像一般的dll调用算什么? DLL/COM Redirection on Windows.
既然SxS assembly那么好, 那我们怎么自己建一个呢? 这是一个相当相当麻烦的过程.... 我都懒的看了.
Guidelines for Creating Side-by-side Assemblies
Installing Side-by-side Assemblies



