Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt DLL deployment on Windows

I have a Plug-in for an application from another company. My plug-in uses Qt so it needs the Qt DLLs. My problem is that all versions of 4.x Qt Dlls are called the same, e.g. :QtCore4.dll. It is quite possible that some other plugin, or another application which inserted itself into the PATH environment variable, has put Qt dlls in the applications folder. In that case, the plug-in will not start as it is expecting a different version of the DLL.

  • Q1. What is the suggested common practice for DLL deployment ?
  • Q2. What if the host application uses a different version of Qt. Would windows allow the host application and the plug-in to use different versions () ?

Thanks!

like image 246
Paul Baumer Avatar asked May 15 '09 12:05

Paul Baumer


3 Answers

A1: Best practice: put the DLL in the directory of the executable. It will look there first for loading the DLL. This is common practice.

A2: If somehow the application uses a different version of Qt and the module you are describint requires a later or specific version, it might cause a problem (not work, crash, etc).

With static Linking you would also have to consider license restrictions of Qt. LGPL is happy as long as the library is dynamically loaded at runtime and can be separated from the application. This only applies if you do not release your source, etc.

Also, your installer should set up access to those files so that they are protected from being overwritten by some other rogue application.

like image 111
Klathzazt Avatar answered Oct 03 '22 18:10

Klathzazt


Just to help others with this problem: QT DLL's are guaranteed to be the same (or at least binary compatible) for all 4.X Versions. (same for all 3.X Versions and so on) so there will be no Problem. This is also the reason wy there is no second number in the Qt dll naming.

like image 39
nobody Avatar answered Oct 03 '22 18:10

nobody


With versions of Windows since XP (i.e. XP, 2003, Vista, 2008, and Win7), you can use the side-by-side assemblies or DLL redirection. In either case, essentially what you're doing is including a small text file that tells the operating system that you need to use the specific version of the DLLs you included in the same directory as the executable.

These are lesser-known features, but they can really save your butt from "DLL Hell".

like image 30
ewall Avatar answered Oct 03 '22 20:10

ewall