Visual Studio 2019可以将所需的DLL打包在一个小的.exe文件中吗? [英] Can Visual Studio 2019 pack the DLLs it requires in just a small .exe file?

查看:1762
本文介绍了Visual Studio 2019可以将所需的DLL打包在一个小的.exe文件中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Visual Studio 2019使用C ++ WinAPI制作了Windows应用程序。
完成后,将其构建并在计算机上执行。完美运作。
然后我发给了没有Visual Studio的朋友。它说需要打开 msvcp140d.dll, ucrtbased.dll, vcruntime140_1d.dll和 vcruntime140d.dll。

I made a Windows application with C++ WinAPI by using Visual Studio 2019. After finishing, I built it, and executed with my computer. It works perfectly. Then I sent to my friend who didn't have Visual Studio. It said that it needs "msvcp140d.dll" "ucrtbased.dll" "vcruntime140_1d.dll" "vcruntime140d.dll" to open it.

然后我在我的电脑中找到了它们。计算机,将它们与我的应用程序放在同一目录中,然后将其发送给我的朋友。

Then I found them in my computer, put them in the same dir with my application, and sent them to my friend. It worked fine, too.

但是我的问题是有什么方法可以将它们与Visual Studio 2019打包在一起吗?

But My question is "Is there any way to pack them with just Visual Studio 2019?" A small application with lots of DLLs is just a little bit weird.

推荐答案

首先,您发送的是错误的文件。 后缀为 d 的文件仅用于调试 ,并且不得 / p>

First you're sending the wrong files. Files with d suffix like that are for debugging only and must not be distributed


您不能重新分发Visual Studio中包含的所有文件。您只允许重新分发Redist.txt或在线 REDIST列表中指定的文件。不能重新分发应用程序的调试版本和各种Visual C ++调试DLL。有关更多信息,请参见选择部署方法。

You cannot redistribute all of the files that are included in Visual Studio; you are only permitted to redistribute the files that are specified in Redist.txt or the online "REDIST list." Debug versions of applications and the various Visual C++ debug DLLs are not redistributable. For more information, see Choosing a Deployment Method.

确定要重新分发的DLL

最终可执行文件必须是在发布模式下编译并使用这些DLL的发布版本。不要发布调试二进制文件。由于添加了用于调试目的的逻辑,它们的运行速度非常慢

Final executable files must be compiled in release mode and use the release version of those DLLs. Don't give out debug binaries. They're seriously slow due to the logics added for debugging purposes

,您实际上并不需要发送DLL,但应告诉用户安装相应的 VC可再发行程序包。这是运行时 CRT )用于Visual Studio项目,其中包含诸如printf,memcpy ...之类的功能。如果您在项目中不使用任何DLL,则无需查找其他DLL。

And you don't actually need to send the DLLs but you should tell the user to install the corresponding VC redistributable package. It's the runtime (CRT) for Visual Studio projects containing functions like printf, memcpy... for you. You don't need to find any other DLL if you don't use any DLLs in the project

还可以通过更改选项 / MD / MT 。这样,最终的exe文件将是自包含的(不需要其他运行时DLL),但文件也将更大,并且在更新软件包以修复错误或性能问题时,您将失去使用较新的库功能的能力

It's also possible to link the runtime library statically by changing the option /MD to /MT. That way the final exe file will be self-contained (no need for additional runtime DLLs) but it'll also be larger and you lose the ability to use the newer library functions when the package is updated to fix bugs or performance issues

另请参见

  • Compile to a stand-alone executable (.exe) in Visual Studio
  • Compile C in Visual Studio 2012 without MSVCRT runtime
  • How to make a Single Executable VS 2010

这篇关于Visual Studio 2019可以将所需的DLL打包在一个小的.exe文件中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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