How to use Qt 'windeployqt' on Linux / Fedora

I am currently trying to cross-compile my Qt applications on a Fedora 21 machine to Windows (32 bits, for now). Compilation works without problems, but no deployment. Of course, I could copy all the necessary files from directories, but I think this is a waste of time, so I want to use the Qt tool 'windeployqt'. But whenever I call it, for example. in Qt Creator, as a build step, it simply displays this message (my test application is called day_404: D):

Unable to find dependent libraries of /home/marius/Entwicklung/build-day_404-Windows_32bit-Release/release/day_404.exe :Not implemented. 

Do any of you know how to fix this and use windeployqt without using Windows?

Thanks in advance, Marius

+5
source share
1 answer

The windeployqt tool does not seem to be used in Fedora 23. It relies on qmake access, so it does not work in the mingw cross-compilation environment, where you create using mingw32-qmake-qt5 (or mingw64-qmake-qt5 ). Even if this problem is fixed, it will not work with Qt5 projects using mingw64-cmake .

A relatively simple way to get a list of all the DLLs that you need to copy for deployment is to run the application under wine and trace all the DLL loads.

For example, for example:

 $ WINEDEBUG=+loaddll wine ./myapp 2> dll.log 

The dll paths can be extracted as follows:

 $ grep Loaded dll.log | grep -v 'system32\|:load_builtin_dll' \ | awk -F'"' '{print $2}' \ | sed -e ' s@ \\\\@/@g' -e 's/^[AZ]://' \ | sort > dll.lst 

The dll.lst file looks like this for a typical Qt5 project compiled with mingw64:

 /path/to/cwd/myapp.exe /path/to/cwd/project.dll [..] /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libpng16-16.dll /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libstdc++-6.dll /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libxml2-2.dll /usr/x86_64-w64-mingw32/sys-root/mingw/bin/Qt5Core.dll /usr/x86_64-w64-mingw32/sys-root/mingw/bin/Qt5Gui.dll /usr/x86_64-w64-mingw32/sys-root/mingw/bin/Qt5Widgets.dll /usr/x86_64-w64-mingw32/sys-root/mingw/bin/zlib1.dll /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/imageformats/qgif.dll /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/imageformats/qico.dll /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/imageformats/qjpeg.dll /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/platforms/qwindows.dll 

Then you can deploy these files as follows:

 $ mkdir -p "$deploy_dir"/{imageformats,platforms} $ for i in imageformats platforms ; do grep "/plugins/$i" dll.lst | xargs -r cp -t "$deploy_dir"/$i done $ grep -v '/plugins/' dll.lst | xargs -r cp -t "$deploy_dir" 

Wine Configuration

To run a cross-compiled binary under wine, the dll mingw directory must be added to the wine path, for example. via:

 sed 's/^\("PATH".*\)"$/\1;Z:\\\\usr\\\\x86_64-w64-mingw32\\\\sys-root\\\\mingw\\\\bin"/' \ -i $HOME/.wine/system.reg 

The file ~/.wine/system.reg automatically created by wine if it does not already exist.

PELDD

You can also use the peldd tool to get a list of all the DLLs that the Windows binary depends on. The tool works on Linux, for example:

 $ peldd myapp.exe -a -p . \ | sed -e ' s@ ^\./@'"$PWD"'/@' -e ' s@ ^\([^/]\)@'"$PWD"'/\ 1@ ' \ | sort > dll2.lst 

The tool transits all dependencies compiled into binary files, but - DLLs that are conditionally loaded at runtime (think dlopen() , think Qt plugin) do not leave traces in binary headers. In contrast, when working under wine, these DLLs are written. For our example, this could be:

 /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libjpeg-62.dll /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/imageformats/qgif.dll /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/imageformats/qico.dll /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/imageformats/qjpeg.dll /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/platforms/qwindows.dll 
+3
source

All Articles