Search code examples
c++windowsqtdlldllimport

Choosing from multiple DLL versions


Today I build my application and packaged the installer with QtIF. It worked nice on my computer but complained about missing msvcp140_1.dll in another computer.

Then I run find . -iname "msvcp140_1.dll" and found more than five different ones on my computer, I checked the md5sum.

Then I spend the time to try all of them on the other computer and all seem to work fine. No more complains about missing DLL.

How should I choose between the DLLs? Just pick any seems too easy.

Is there someway to inspect the DLLs, to check for a version?

I believe that DLL was a dependency from another binary included in my application, was not that the QtIF failed to include it.


Solution

  • Call the MS Redist Installer from your Installer. This can be done quietly, so that the end user does not notice it.

    • Find the vcredist_x64.exe file (or vcredist_x32 for 32 Bit applications), add it to your installer,
    • let it extract to the "TEMP" folder
    • and then call vcredist_x64.exe /quiet at the end of your install.

    This has several advantages:

    • You will definitely copy all required files to the users computer.
    • Should new versions of the runtime library be released by Microsoft and should they already be on your users computer, your code will use the newer versions, which may include bugfixes.
    • Windows Update may also update the libraries.

    That said, it is possible to copy the DLLs themselves, but you should make sure a) you choose the right ones b) they come from a trustworthy place, i.e. your VS installation folder c) reside in the same directory as the executable - otherwise you will run into trouble with manifests.

    The reason you might want to include the DLLs directly is if you want to reduce the overall size of your installer.

    We did this a couple of years with our products, but finally gave in and simply used the vcredist_x64.exe, even if that increased the installer binary another couple of MB in size. But in the long run that's the easiest way.

    I think (not sure), msvcp140_1.dll is an additional DLL for the VS 2019 runtime. VS 2017 runtime does not need this, but the new one does.