c - Visual Studio 2013 : C Application on any Windows version

标签 c windows dll visual-studio-2013

情况

我有一个用 C 语言编写的 Visual Studio 2013 应用程序。它在我的计算机 (Windows 7) 和我测试过该应用程序的其他 Windows 7 计算机上运行完美。

问题

为了让我的应用程序正常工作,必须安装 Microsoft Visual C++ Redistributable,否则还需要一些其他 .dll 文件(例如 MSVCR120.DLL)。当我在 Windows XP 上尝试这个时,我遇到了以下错误:

C:\path\to\app.exe is not a valid Win32 application

并没有找到解决这个问题的方法。

问题

我如何才能解决所有问题并拥有一个可在任何 Windows 系统上运行的 .exe 文件,而无需额外的文件或安装程序,而无需考虑其配置?

奖励问题

这些 MSVCR***.dll 文件是什么?

最佳答案

您可以静态链接到 vc 运行时,这样就无需安装依赖项。请注意,.exe 会更大,因为编译了依赖项。

Project Settings -> C/C++ -> Code Generation 中为发布设置 /MT,为调试设置 /MTd

您还可以在General -> Platform Toolset 中设置v120_xp,使您的程序能够在Windows XP 中运行(http://supportxpdotcom.wordpress.com/2013/07/16/xp-targeting-support-in-the-visual-studio-2013-preview/)

MSVCR*** 文件是 C 运行时库文件,其中包含程序中使用的 C 运行时函数的功能。当您静态链接一个程序时,您将它们编译到 .exe 中,因此不必单独分发它们。 ( http://msdn.microsoft.com/en-us/library/aa272081(v=vs.60).aspx )

关于c - Visual Studio 2013 : C Application on any Windows version,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27280114/

相关文章:

c - Linux 克隆调用的最小堆栈大小?

ruby - Windows Liquid 异常 : Failed to get header 上的 Jekyll

python - C DLL 在 C++ 程序中加载,而不是在 python Ctypes 中加载

c++ - 遇到微软弯路的麻烦

c - 我的 SHA256 哈希函数有什么问题?

if 语句中的 OR 条件链

c - 从特定索引 C 读取 char*

windows - 为什么批处理文件中的特殊字符打印为问号?

java - 当我从cmd运行jar时发生InputMismatchException,如果从idea运行则不会发生

c# - regsvr32 文件已加载,但入口点 dllregisterserver