交叉编译 Qt 5 应用程序(主机:Fedora 19/64 位,目标:Windows 32 位)后,我执行以下步骤来部署可执行文件:
$ DEST=/windows/testdir
$ cp /usr/i686-w64-mingw32/sys-root/mingw/bin/*.dll $DEST
$ mkdir $DEST/platforms
$ cp /usr/i686-w64-mingw32/sys-root/mingw/lib/qt5/plugins/platforms/qwindows.dll\
$DEST/platforms
$ cp release/main.exe $DEST # the cross-compiled Qt5 binary
我在 Windows 上测试它是这样的:
say /windows is mounted on f:
start command prompt window
f:
cd testdir
main
我得到了:
无法加载平台插件“windows”。可用平台有:
Microsoft Visual C++ 运行时库 此应用程序已请求运行时以不寻常的方式终止它。请联系应用程序的支持团队以获取更多信息。
我真的不相信第一条消息,因为:
a) 上述步骤过去有效(在同一个 Fedora 19 系统上执行)
b) 平台目录在 qt docs 中记录。
改变的是现在应用程序在对话框中包含了一些 PNG/JPG(通过 Qt 的资源文件系统读取,作为 QIcons)。
因此,我还复制了一些插件:
$ cp -r /usr/i686-w64-mingw32/sys-root/mingw/lib/qt5/plugins $DEST
这无助于解决上述问题。
结论
有没有办法调试像这样的动态运行时链接器问题?
我可以指示它以某种方式获得应用程序/链接器尝试加载的 dll 以及它的查找在哪里的输出吗?(以及为什么他们失败了......)
例如,这样的事情会很棒:
ldd: main.exe -> load of foo.dll in work-dir failed (no such file)
ldd: main.exe -> load of bar.dll in work-dir/platforms failed (wrong file format)
ldd: main.exe -> load of baz.dll in work-dir successful
...
编译步骤
我使用以下步骤在 Fedora 19 上进行交叉编译:
$ mingw32-qmake-qt5 main.pro -o win32.mf
$ mingw32-make -f win32.mf
$ # -> binary is created in release/main.exe
葡萄酒
我出于测试目的查看了葡萄酒。这很有帮助,因为它在找不到 DLL 时会显示错误消息,例如:
$ wine $DEST/main.exe
err:module:import_dll Library libEGL.dll (which is needed by L"Z:\\usr\\i686-w64-mingw32\\sys-root\\mingw\\lib\\qt5\\plugins\\platforms\\qwindows.dll") not found
err:module:import_dll Library libjpeg-62.dll (which is needed by L"Z:\\usr\\i686-w64-mingw32\\sys-root\\mingw\\lib\\qt5\\plugins\\imageformats\\qjpeg.dll") not found
有趣的是,它直接在Z:\\usr\\i686-w64-mingw32\\sys-root\\mingw\\lib\\qt5\\
.
但是,当所有需要的 DLL/usr/i686-w64-mingw32/sys-root/mingw/bin/*.dll
都被复制到 $DEST 时,wine 运行同样main.exe
正常 - 在本机 Windows (7) 上,我得到上述错误框。