在VS中编译C ++,而在运行时不需要MSVCP120D.dll [英] Compile C++ in VS without requiring MSVCP120D.dll at runtime

查看:463
本文介绍了在VS中编译C ++,而在运行时不需要MSVCP120D.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个可以在任何Windows机器上运行的二进制文件,而没有安装可视化的c ++东西(我假设这是MSVCP120D.dll是什么,但是我的搜索对于这是什么实际上并不是很有成效) 。我做了一个任务的游戏,想要有其他人(没有安装VS的非开发人员),帮助我测试,但他们不断收到错误,说上面的DLL丢失。我没有使用任何Visual C ++的东西,并且设置了/ Za标志来确保它只是ANSI C ++。 Visual Studio是否支持编译ANSI C ++,如果是,如何不使用Visual C ++的东西,如果不支持我应该使用什么编译器?

解决方案

您可以看到这里,MSVCP DLL是平台的C ++标准库的实现。简单来说,这意味着你不能分发你的应用程序,而不需要这些库提供的东西。无论平台如何,所有编译器都需要实施标准库。通常这是以图书馆的形式分发。



然而,您可以分发应用程序,以便将内容直接内置到程序中,而不是在一个单独的DLL。为此,您必须将您的应用程序静态链接到标准库。



有几种方法可以实现此目的。一种方法是在项目设置中。在项目>配置属性>C / C ++代码生成>运行时库中,选择多线程(/ MT)而不是Mutithreaded(静态)。






顺便说一句,上面提到的MSVCP120D.dll中的D表示调试。这意味着您正在尝试分发您的程序的调试构建。你应该(几乎)永远不会这样做。分发发布版本。


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?

解决方案

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.

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.

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)".


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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆