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

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

问题描述

我试图做一个二进制文件,可以运行在任何Windows机器上没有安装visual c ++东西(我假设这是什么MSVCP120D.dll,但我的搜索并不是非常富有成果,这是什么) 。我做了一个任务的游戏,并希望有其他人(非开发人员没有VS东西安装),帮助我测试,但他们不断收到错误说,上述DLL丢失。我不使用任何Visual C ++东西,并设置了/ Za标志,以确保它只是ANSI C ++。 Visual Studio支持编译ANSI C ++,如果是这样,如何使它不使用Visual C ++的东西,如果它不支持这个编译器应该使用?

解决方案

正如您可以在这里看到的,MSVCP DLL是平台的C ++标准库的实现。总之,这意味着你不能分发你的应用程序,而不需要这些库提供的东西。所有编译器不管平台如何,都需要某种标准库的实现。通常,这是以库的形式分发的。



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



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



< hr>

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


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 "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天全站免登陆