8

Currently I'm trying to deploy a Qt application for Windows using MinGW and CMake from Linux. I used MXE to prepare building environment (install mingw32 and compile Qt5 shared libraries). I've written CMakeList.txt and a toolchain script, and they build my application OK.

The thing I can't achieve is to deliver shared Qt dlls to my built executable.

Here is my Toolchain file: http://pastebin.com/gh7kSda4

This is my CMakeLists.txt: http://pastebin.com/wHA7f7Sj

Here is the excerpt from that script, containing the installation part:

# Installation.
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/${TOOLCHAIN}-Bundle)
install(TARGETS mEyeSaver
        RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
install(CODE "
        include(BundleUtilities)
        fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/mEyeSaver${TOOLCHAIN_EXECUTABLE_FORMAT}\" \"\" \"${QT5_PATH}/bin\")
" COMPONENT Runtime)

As you can see, I use fixup_bundle for achieving my goal.

After I type make install I get the following output: http://pastebin.com/DymaH1Mu

After that there is nothing except mEyeSaver.exe in the x86_64-w64-mingw32-Bundle folder. No dlls were copied. I'm sure there were needed Qt dlls in the ~/mxe/usr/x86_64-w64-mingw32.shared/qt5/bin folder. But there is still something I'm doing wrong.

How to fix the problem? Thank you

Update

I've rethought what I'm doing and came to a point that maybe fixup_bundle just can't analyze dependencies for Windows executable, because Linux ldd (which it uses) has nothing to do with a Windows app. So I've edited my question.

Is there any easy way to get dependency libraries with CMake (or maybe another tool) for Windows executable without copying them directly?

Community
  • 1
  • 1
mvlabat
  • 577
  • 4
  • 17
  • 1
    Any success? Unless I'm doing things wrong this is a great question. Essentially, how to "install" the Qt libraries needed at runtime. – joe Jul 06 '17 at 21:55
  • 1
    @joe, sorry it took me so long to answer. Unfortunately, I haven't find the desired solution. This is the farthest I could get: `objdump -p app.exe | grep DLL` (https://linux-tips.com/t/how-can-i-find-library-dependencies-of-a-windows-dll/328/2). So you'll have to manually parse the output with your build script and copy the needed libraries, excluding ones like `KERNEL32.dll`. One important note is that you won't see deeper level dependencies of DLLs listed, so you'll also have to iterate through them recursively. – mvlabat Sep 06 '17 at 12:36

1 Answers1

1

In last cmake version there is file GET_RUNTIME_DEPENDENCIES command to get binary dependencies at install time.

ephemerr
  • 1,833
  • 19
  • 22