【发布时间】:2014-03-18 20:56:55
【问题描述】:
好吧,我花了一天时间寻找解决方案并阅读了所有内容,但我无法部署我的 Qt 应用程序,所以我决定问一下。
我在 VS 2013 Ultimate 中通过 Visual Studio 插件使用 Qt 5.2.1,qt 版本是 msvcr2012。我有 Qt 5.2 的 x86 版本(现在是 Qt 下载页面底部的第 3 个版本)。
我的目标是 Win7 32 位。
我的操作系统是 Windows7 64 位,我正在为 win32、release /o2 (max speed) 优化、/MD (dynamic C runtime) 构建应用程序,并链接库:
qtmain.lib
Qt5Core.lib
Qt5Gui.lib
Qt5Widgets.lib
Qt5PlatformSupport.lib //this one is added by me, the others are automatically set with the Qt-AddIn template.
我构建它,并在发布文件夹中放入以下内容:
编辑:由于我的编译器版本,我还分发了 vs2012 dll.s,如您所见。
.../release /plugins /platforms
我已经设置了额外的库路径(只是为了 100% 的机会找到它们):
void registerPluginsDir(QDir& exeDir)
{
QString pluginsRelPath = "plugins";
QString platformsRelPath = "platforms";
QString pluginsPath = exeDir.absoluteFilePath(pluginsRelPath);
QString platformsPath = QDir(pluginsPath).absoluteFilePath(platformsRelPath);
QStringList pathes = QCoreApplication::libraryPaths();
pathes << pluginsPath;
pathes << platformsPath;
QCoreApplication::setLibraryPaths(pathes);
for (auto i : pathes)
qDebug() << i << "\n";
};
int main(int argc, char *argv[])
{
QString exePath = QString::fromUtf8(argv[0]);
QFileInfo exeInfo(exePath);
QDir exeDir(exeInfo.absolutePath());
registerPluginsDir(exeDir);
QApplication a(argc, argv);
KeyGenerator w;
w.show();
return a.exec();
};
路径是正确的。使用调试器,我看到它们是从我的应用程序文件夹中加载的,而不是从 Qt 主文件夹中加载的。
使用depends.exe 我检查了所有内容。我只收到 2 个警告,没有错误:
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
我已经根据在 Visual Studio 中调试应用程序时加载的 .dll-s 复制了 .dll-s。 depends.exe 和 debug 之间的唯一区别是,在 VS 系统中 dll-s 是从 SysWOW64 加载的,而不是 system32。
所有这些都在我的(开发者)电脑上运行没有任何错误,但在测试(在 Microsoft Virtual PC 上运行的 Win7 32 位)电脑上我得到了“臭名昭著”的错误:
Failed to load platform plugin “windows”. Available platforms are:
(and here there are the full pathes to the .dll-s,
eg: D:\cproj\keygen\win32\Release\plugins\platforms\qwindows.dll, so it must have found them.
我也关注了这个:http://qt-project.org/wiki/Deploy_an_Application_on_Windows.
重命名 Qt-dir,控制台仅将发布文件夹输出为库输入(而不是像我的第一个测试那样的 Qt 文件夹)。它从应用程序文件夹中加载了 dll-s,启动良好。但是,在我的虚拟 PC 或我兄弟的 pac(Win7 32 位)上,它给了我错误。ˇ关于此的图片:
如何在 32 位机器上运行它?我对每个版本都进行了尝试,release-win32,debug-win32,它们都不起作用。我无法在更多机器上测试它,在 XP 上它甚至无法加载 C 运行时,但这不是目标平台。
更多信息请评论。
编辑:目标 pc 上的 Dependency walker 显示与开发 pc 上的相同。它仍然可以找到插件,但无法加载。
【问题讨论】:
-
“我知道即使它们是'静态'库”那些被称为import libraries。
-
感谢您澄清这一点。那是我没有完全理解的。
标签: windows qt visual-c++ visual-studio-2012 deployment