Visual Studio 2019 能否将它需要的 DLL 打包到一个小的 .exe 文件中?
Can Visual Studio 2019 pack the DLLs it requires in just a small .exe file?
我使用 Visual Studio 2019 使用 C++ WinAPI 创建了一个 Windows 应用程序。
完成后,我构建了它,并在我的电脑上执行。它工作得很好。
然后发给我没有Visual Studio的朋友。说是需要"msvcp140d.dll""ucrtbased.dll""vcruntime140_1d.dll""vcruntime140d.dll"才能打开
然后我在我的电脑里找到它们,把它们和我的应用程序放在同一个目录下,然后把它们发给我的朋友。它也很好用。
但我的问题是 "Is there any way to pack them with just Visual Studio 2019?" 带有大量 DLL 的小型应用程序有点奇怪。
这并不奇怪,许多应用程序将它们的依赖项与它们的二进制文件放在一起。
如果您仍然不想提供 DLL,您可以检查用户是否在他的计算机上安装了所需的库,然后处理一个小的安装程序,它将添加缺少的库。
如果您仍想 "pack them",则可能需要改用静态链接。看看this answer.
首先你发送了错误的文件。 类似d
后缀的文件仅用于调试并且不得分发
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.
最终的可执行文件必须在发布模式下编译并使用那些DLLs的发布版本。不要给出调试二进制文件。由于为调试目的添加的逻辑,它们非常慢
而且您实际上不需要发送 DLL,但您应该告诉用户 安装相应的 VC redistributable package. It's the runtime (CRT) 用于包含 [=11] 等功能的 Visual Studio 项目=], memcpy
... 给你。如果项目中没有使用任何DLL,则无需查找任何其他DLL
也可以通过 changing the option /MD
to /MT
link 静态地 运行时库 。这样,最终的 exe 文件将是独立的(不需要额外的运行时 DLL),但它也会更大,并且当更新包以修复错误或性能问题时,您将失去使用较新库函数的能力。同样,无论您是 link 静态还是动态
,都必须在发布模式下编译
另见
- 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 使用 C++ WinAPI 创建了一个 Windows 应用程序。 完成后,我构建了它,并在我的电脑上执行。它工作得很好。 然后发给我没有Visual Studio的朋友。说是需要"msvcp140d.dll""ucrtbased.dll""vcruntime140_1d.dll""vcruntime140d.dll"才能打开
然后我在我的电脑里找到它们,把它们和我的应用程序放在同一个目录下,然后把它们发给我的朋友。它也很好用。
但我的问题是 "Is there any way to pack them with just Visual Studio 2019?" 带有大量 DLL 的小型应用程序有点奇怪。
这并不奇怪,许多应用程序将它们的依赖项与它们的二进制文件放在一起。
如果您仍然不想提供 DLL,您可以检查用户是否在他的计算机上安装了所需的库,然后处理一个小的安装程序,它将添加缺少的库。
如果您仍想 "pack them",则可能需要改用静态链接。看看this answer.
首先你发送了错误的文件。 类似d
后缀的文件仅用于调试并且不得分发
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.
最终的可执行文件必须在发布模式下编译并使用那些DLLs的发布版本。不要给出调试二进制文件。由于为调试目的添加的逻辑,它们非常慢
而且您实际上不需要发送 DLL,但您应该告诉用户 安装相应的 VC redistributable package. It's the runtime (CRT) 用于包含 [=11] 等功能的 Visual Studio 项目=], memcpy
... 给你。如果项目中没有使用任何DLL,则无需查找任何其他DLL
也可以通过 changing the option /MD
to /MT
link 静态地 运行时库 。这样,最终的 exe 文件将是独立的(不需要额外的运行时 DLL),但它也会更大,并且当更新包以修复错误或性能问题时,您将失去使用较新库函数的能力。同样,无论您是 link 静态还是动态
另见
- 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