问题描述
我正在尝试制作一个二进制文件,它可以在没有安装 Visual C++ 东西的情况下在任何 Windows 机器上运行(我假设这就是 MSVCP120D.dll 的内容,但是我的搜索对于这实际上是什么并不是很有成效).我为一项任务制作了一个游戏,并希望让其他人(没有安装 VS 的非开发人员)帮助我测试它,但他们不断收到错误消息,说缺少上述 dll.我没有使用任何 Visual C++ 的东西,并且设置了/Za 标志以确保它只是 ANSI C++.Visual Studio 是否支持编译 ANSI C++,如果支持,我该如何让它不使用 Visual C++ 的东西,如果它不支持这个,我应该使用什么编译器?
I'm trying to make a binary that can be run on any windows machine without the visual c++ stuff installed (I'm assuming that's what MSVCP120D.dll is however my searching was not very fruitful as to what this actually is). I made a game for an assignment and wanted to have other people (non-devs without VS stuff installed), help me test it but they kept getting errors saying that the above dll is missing. I'm not using any Visual C++ stuff and have the /Za flag set to ensure that it's just ANSI C++. Does Visual Studio support compiling ANSI C++ and if so how do I go about making it not use Visual C++ stuff, if it doesn't support this what compiler should I use?
推荐答案
如您所见 此处,MSVCP DLL 是 C++ 标准库的平台实现.简而言之,这意味着您不能在不需要这些库提供的东西"的情况下分发您的应用程序.无论平台如何,所有编译器都需要某种标准库的实现.通常以库的形式分发.
As you can see here, the MSVCP DLL is the platform's implementation of the C++ Standard Library. In short what that means is you cannot distribute your application without needing the "stuff" that these libraries provide. All compilers regardless of platform would need some kind of implementation of the Standard Library. Typically this is distributed in the form of libraries.
但是,您可以分发您的应用程序,以便将东西"直接内置到您的程序中,而不是在单独的 DLL 中提供.为此,您必须将应用程序静态链接到标准库.
However you can distribute your application so that the "stuff" is built in to your program directly, rather than being shipped in a separate DLL. In order to do this, you must statically link your application to the Standard Library.
有几种方法可以实现这一点.一种方法是在项目设置中.在项目">配置属性">C/C++ 代码生成">运行时库"中,选择多线程(/MT)"而不是多线程(静态)".
There are a few ways to accomplish this. One way is in Project Settings. In "Project" > "Configuration Properties" > "C/C++ Code Generation" > "Runtime Library", choose "Multithreaded (/MT)" as opposed to "Mutithreaded (Static)".
顺便说一下,你上面提到的MSVCP120D.dll"中的D"是指调试".这意味着您正在尝试分发程序的 调试 版本.你应该(几乎)永远不要这样做.而是分发发布版本.
By the way, the "D" in "MSVCP120D.dll" you mentioned above means "Debug." This means that you are trying to distribute a debug build of your program. You should (almost) never do this. Distribute release builds instead.
这篇关于在 VS 中编译 C++,而无需在运行时使用 MSVCP120D.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!