广泛使用的解决方案是将所有必要的库放在应用程序的文件夹中。
图书馆应用程序需要什么?
运行应用程序并查看错误消息:
The program can't start because <Library name> is missing from your computer.
Try reinstalling the program to fix this problem
库集依赖于 Qt 版本。运行多次应用程序,每次复制所需的库,您都会找到应用程序所需的内容。
就我而言(Qt 5.2.1)有
icudt51.dll,
icuin51.dll,
icuuc51.dll,
libgcc_s_dw2-1.dll,
libstdc++-6.dll,
libwinpthread-1.dll,
Qt5Core.dll,
Qt5Gui.dll,
Qt5Widgets.dll.
您可以在 Qt 安装文件夹中找到所有库。但是不要使用Tools\QtCreator 文件夹中的库,因为QtCreator 有这些库的另一个版本!
如果出现错误:
此应用程序无法启动,因为它无法找到或加载他的 Qt 平台插件windows。重新安装应用程序可能会解决此问题。
您应该创建文件夹 platforms 并将 qwindows.dll 复制到其中。
如果您仍然遇到错误,您应该在应用程序的文件夹中创建 qt.conf 文件,其内容为:
[Paths]
Plugins=plugins
https://qt-project.org/forums/viewthread/37265 中描述了此解决方案
有关qt.conf 的更多信息,请访问http://qt-project.org/doc/qt-5/qt-conf.html
在最新版本的 Qt 中,您可以找到部署工具(从 5.2 开始)。该工具为应用程序找到必要的库并复制到应用程序文件夹中。你可以像这样运行它:
call c:\Qt\QtX.Y.Z\X.Y.Z\mingw48_32\bin\qtenv2.bat
cd /d "c:\path\to\your\application\folder"
windeployqt.exe your_application.exe
通常它运作良好。但是我注意到有些库没有被复制,但是你可以通过文章开头描述的方法找到。您可以在以下位置找到更多有用的信息
http://qt-project.org/doc/qt-5/windows-deployment.html
在极少数情况下,如果某些库丢失但未出现在上面的错误消息中,您可能会收到此错误。示例:Qt 5.1.1: Application failed to start because platform plugin "windows" is missing
我没有遇到这种情况,所以我不能说更多。