How can I use CMake to get dependencies for Windows app while building it from Linux?
Asked Answered
T

1

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?

Turn answered 16/3, 2016 at 9:11 Comment(2)
Any success? Unless I'm doing things wrong this is a great question. Essentially, how to "install" the Qt libraries needed at runtime.Fairminded
@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 (linux-tips.com/t/…). 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.Turn
A
1

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

Accusation answered 3/2, 2020 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.