3

在 vista 上使用 Visual Studio 2008 编译一个简单的 C++ 项目后,一切都在原始 vista 机器和其他 vista 计算机上运行良好。但是,将其移至 XP 框会导致错误消息:“应用程序无法启动,因为应用程序配置不正确”。

我该怎么做才能使我编译的 EXE 在 XP 和 Vista 上运行?几个月前我也遇到了同样的问题,只是在项目上摆弄了一些设置来修复它,但我不记得我改变了哪些。

4

5 回答 5

6

您需要在目标计算机上安装 Visual Studios 2008 运行时:

http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en

或者,您也可以静态链接运行时,在项目属性窗口中转到:

c++ -> 代码生成 -> 运行时库并选择“多线程/MT”

于 2008-09-17T20:43:11.133 回答
1

您需要将运行时可再发行文件安装到您尝试运行应用程序的机器上。

2008 年的可再发行产品在这里

2005 年的可再发行产品在这里

它们可以并排安装,以防您需要两者。

于 2008-09-17T20:40:39.967 回答
1

您可能需要将 VC 运行时与您的应用程序一起分发。有多种方法可以做到这一点。 Microsoft Visual C++ 团队的这篇文章最好地解释了在使用 Visual Studio 2005 或 2008 时分发这些依赖项的不同方法。

如文章所述,尽管您可以下载 Redistributable 安装程序包并在客户端计算机上简单地启动它,但这几乎总是不是最佳选择。通常有更好的方法来包含所需的 DLL,例如,如果您通过 Windows 安装程序分发,则包含合并模块;如果您只想分发压缩文件夹,则包含 App-Local 副本。

另一种选择是静态链接运行时库,而不是与您的应用程序一起分发它们。此选项仅适用于不加载其他 DLL 的独立 EXE。您也不能对其他应用程序加载的 DLL 执行此操作。

于 2008-09-17T20:57:58.897 回答
0

静态链接到运行时是最简单的。

c++ -> 代码生成 -> 运行时库并选择“多线程/MT”

However, this does make your executable a couple hundred KByte larger. This might be a problem if you are installing a large number of small programs, since each will be burdened by its very own copy of the runtime. The answer is to create an installer.

New project -> "setup and deployment" -> "setup project"

Load the output from your application projects ( defined using the DLL version of the runtime ) into the installer project and build it. The dependency on the runtime DLL will be noticed, included in the installer package, and neatly and unobtrusively installed in the correct place on the target machine.

于 2008-09-17T21:11:05.823 回答
0

Visual studio 2005 actually has two

The one for the original release

and the one for SP1

于 2008-09-17T21:38:29.597 回答