0

我们有一个 c++ 应用程序,我最近从 Linux/gcc 移植到使用 Visual Studio 2005 在 Windows 上构建。该应用程序使用第 3 方库,该库仅提供使用优化的 CRT DLL 的 DLL(即它们不提供链接到调试 CRT DLL)。对于 VS2005,这似乎不是问题 = 调试版本在 System32 目录中找到了优化的 CRT DLL。

我现在正在尝试使用 VS2008 构建和运行我们的应用程序,但调试构建无法运行,因为它找不到优化的 CRT DLL (msvc690.dll)。VC9 CRT DLL 被隐藏在具有 GUID 样式名称的目录中 - 我相信这是一个并行程序集,应用程序应该使用应用程序的清单来定位它。但是,在应用程序 exe 中构建和嵌入的清单仅指定调试 CRT 程序集:

<?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.DebugCRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
</assembly>

我不是 Windows 专家(至少不再是),所以这对我来说是全新的。这里的正确解决方案是什么?我需要告诉清单编译器将优化的 CRT DLL 添加到程序集中吗?如果是这样,我该怎么做?

4

1 回答 1

1

行。如果您在 VS 2008 中打开第 3 方库 dll(确保选择 OpenWith>Resource Editor),它是否包含自己的清单?

如果有,或者即使没有,让DependencyWalker查看该第三方库试图链接到的确切运行时 dll 也很有用。

它与 VS2005 而不是 VS2008 一起工作的事实意味着 dll 想要使用 VS2005 运行时的 releasemode 版本:msvcr80.dll

你提到了 msvc690.dll,它并没有给我敲响警钟:Visual Studio 6 使用了简单命名的 msvcrt.dll - 第一个使用版本化 dll 运行时的 Visual Studio 版本是 VS 2003 .NET 或其他东西:msvcrt7.dll

无论如何,如果第 3 方库不包含其自己的清单资源,那么最简单的做法是将依赖程序集引用添加到您的应用程序清单中。

There are a number of ways of doing this - you can create a manifest fragement as a XML file and add it to your applications "Configuration Properties > Manifest Tool > Input and Output > Additional Manifest Files"

I find the most convenient way of merging additional dependent assembly directives in VS2008 is to use the linkers /manifestdependency command line option.

If you add the following code snippet to a file in your project, it will give the linker the necessary hint:

#define X_CRT_ASSEMBLY_VERSION "9.0.21022.8"
#pragma comment(linker,"/manifestdependency:\"type='win32' "\
    "name='"Microsoft.VC80.CRT' "
    "version='8.0.??.??' "                         \
    "processorArchitecture='x86' "                                 \
    "publicKeyToken='????????'\"")

The ??'s are there because I don't know the version numbers or public key token of the VS2005 libraries off hand. if you can look them up and fill them in, it should go swimmingly.

于 2009-08-20T10:25:47.003 回答