1

Recently I switched from mingw to msvc compiler for my Qt app. I am using Qt5.8. The msvc debugger is from the windows 10 kit (though I develop on Win7 and Win8.1) and the compiler from the vc++2015 build tools. I can run the app locally, but I can't run it on a different, clean computer. I know that I have to copy the compiler specific dll's to the application's executable directory. All the other dlls are found by windeployqt. Still I don't get it to work. I can't ship vc_redist packages the user has to install, due to the requirement to be able to load the app from a pendrive. On the dev machine there are several dlls of the same name, how can I figure out which ones are actually used by the compiled app? Questionable dlls is especially api-ms-win-crt-runtime-l1-1-0.dll.

On the deployment I got those errors:

enter image description here

enter image description here

I also tried Dependency Walker and showed the full paths. I assume the first hierarchy level is the important one, that's why I've hidden deeper hierarchies. I am wondering why the full path shows the dir System32 because isn't this the 64-bit files folder?? I did not target any specific one but my app must be running on x86. Is this a misunderstanding?

enter image description here

EDIT

According to another question and this Microsoft blog update it worked for me when I additionally included all dlls from this folder C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86. There is also a file named ucrtbase.dll. I have no idea why DependencyWalker showed different ones.

Community
  • 1
  • 1
user2366975
  • 4,350
  • 9
  • 47
  • 87
  • `how can I figure out which ones are actually used by the compiled app?` You can use [Dependency Walker](http://www.dependencywalker.com) to find that out, however, it's strange that `windeployqt` doesn't put these in place with all the rest dlls. – Dmitry Mar 23 '17 at 08:15
  • I should have added that I tried Dependency Walker. I will add an image. Thanks – user2366975 Mar 23 '17 at 08:18
  • @Dmitry `windeployqt` do not plut the msvc DLLs with the other DLLs as the recommended deployment method is that the MSVC runtime should be installed on the end user computer. So instead `windeployqt` put the `vc_redist` setup that you should install as part of your own setup program. – Benjamin T Mar 23 '17 at 08:26
  • @BenjaminT, thanks, good to know. – Dmitry Mar 23 '17 at 08:29
  • Practically there is no vc_redist file in the folder after using `windeployqt`. When using windeployqt I only got a warning `Cannot find Visual Studio release redistributable files in C:\Program files(x86)\Microsoft Visual Studio 14.0\VC\redist` – user2366975 Mar 23 '17 at 12:51
  • @user2366975 That's because you have installed an express edition of Visual, which do not ship with the vc_redist setups. You have to get them from Microsoft website (https://www.microsoft.com/en-US/download/details.aspx?id=48145) – Benjamin T Mar 23 '17 at 14:44
  • I do not have visual express installed, but the build tools, because I do not need the IDE. Well perhaps it yields the same, in the end. But anyway I cant ship the redistributable. Thanks for the explanation why it could not be found there. – user2366975 Mar 23 '17 at 15:48

1 Answers1

0

You can use tools such as Dependency Walker to see which DLL is used by any other DLL or exe file. Edit: You can also take a look at Determining Which DLLs to Redistribute on MSDN

Also you could use static linkage to link against the MSVC runtime (i.e use /MT switch instead of /MD (see https://msdn.microsoft.com/en-US/library/2kzt1wy3.aspx). However this would also mean rebuilding Qt, but it would also give you the opportunity to build a static version of Qt, meaning that you would not need to ship any DLL alongside your exe. You can find more info on Qt wiki: Build Standalone Qt Application for Windows

Benjamin T
  • 8,120
  • 20
  • 37
  • Static linkage is not an option due to licensing. – user2366975 Mar 23 '17 at 08:24
  • @user2366975 The licensing is an issue for statically linking Qt, you could still build a dynamic Qt with static linkage to MSVC. – Benjamin T Mar 23 '17 at 08:28
  • Sounds interesting. Do I still need to rebuild Qt for that case? – user2366975 Mar 23 '17 at 08:33
  • @user2366975 Yes because distributed Qt dlls also need msvc dlls. So you need to build your own Qt dll with static linkage to msvc. – Benjamin T Mar 23 '17 at 08:49
  • In [this](https://forum.qt.io/topic/15216/qt-making-qt-perform-static-linking-of-c-runtime-libraries/7) 4 year old thread, I read that `Quick answer is: you can't compile Qt with MSVC statically compiled into Qt libs. it is because memory allocation for objects is done in different places in Qt(like in QtGUI, QtCore etc...) and this objects then shred between this libraries. MT compiles each DLL with own runtime/memory allocation procedure, you can't allocate memory in one DLL and destroy it in another...` – user2366975 Mar 23 '17 at 12:16
  • @user2366975 Forgot about that :-/ – Benjamin T Mar 23 '17 at 14:46