如何部署使用 MSCV 编译的 Qt 应用程序,这样它就不会安装 vc_redist?

How to deploy Qt app compiled using MSCV so that it won't neet vc_redist installed?

有没有一种方法可以部署使用 MSVC 编译的 Qt 桌面应用程序,使其“可移植”(只是 运行 文件夹中的 exe,不安装任何东西,甚至不安装VC_redist)?

当然,如果目标计算机上安装了 Microsoft Visual C++ Redistributable,则可以使用它,但是是否可以 运行 不安装它(例如,将 vcredist 中的一些 dll 放到应用程序的文件夹)?

如果您 build/link 您的应用程序是静态的,您将只有 1 个没有 DLL 的 .exe。第二种方法是使用共享库构建您的应用程序,在运行时您的应用程序将在 PATH 和当前目录中搜索这些 DLL,因此您只需要将所有需要的 DLL 放在该文件夹中即可。你如何管理你的 Qt 库?

正如您所说,您可以使用windeployqt 添加Qt 相关的DLL 和资源。至于其他所需的 DLL,您可以使用 Dependencies 找到它们并手动将它们复制到您的应用程序文件夹中,包括 MSVC DLL。

PS: 我知道手动复制那些 DLL 是低效且容易出错的。不过这就是我问 Is there any way to search and copy all the DLL dependencies?, but I haven't found a tool smart enough to do this chore automatically. You might try those tools mentioned in the comments, like NDepend 的原因。