1

When I release my Qt project, I want to redistribute the QtCore5.dll and Qtxxx.dll files.

How can I make myapp.exe to find them automatically? The best way of doing this seems to be by editing a qt.conf file placed in the same folder as my executable.

myapp.exe is in c:\myapp\bin folder

The dlls are in c:myapp\common folder

Opal
  • 81,889
  • 28
  • 189
  • 210
Pogel
  • 61
  • 1
  • 7

2 Answers2

1

"Better" way is to put your qt.conf into your resources :/qt/etc/qt.conf. This way has highest priority for resolving platform dependencies.

In our project we use cmake to generate necessary qt.conf file: in debug mode we put path to installed Qt binaries and in release - to local (deploy) folder.

Qt5xxx.dll files are linked, so you should place it in same folder, or make them available throught PATH environment variable. If you really want such exotic redistribution system (please, say real reason) - you may create your own platform-specific launcher, that will load necessary .dll's from any path.

Dmitry Sazonov
  • 8,801
  • 1
  • 35
  • 61
  • In main Programm i add QCoreApplication::addLibraryPath(QString::fromLocal8Bit(ToolPathEnv) + "\\common"); QCoreApplication::addLibraryPath(QString::fromLocal8Bit(ToolPathEnv) + "\\common\\plugins"); and i set it in PATH environment variable. The qt.conf is put same directory as myexecutable.myapp.exe and their content is : [Paths] Prefix=$(MyApp_HOME)\common Plugins=plugins – Pogel Apr 28 '15 at 11:36
  • @Pogel, your solution will not work if your application will be stored in folder with complex unicode name. – Dmitry Sazonov Apr 28 '15 at 11:40
  • my application hasn't a folder with complex unicode. – Pogel Apr 29 '15 at 13:06
0

Just put all required dll files into the same directory as your executable.

Note, that there are more files to distribute than just Qt*.dll - you will need proper plugin from platforms subdirectory and many more. Read Qt documentation on deploying application under Windows - it will teach you all required files.

Googie
  • 5,742
  • 2
  • 19
  • 31
  • all required dll are in C:\myapp\common and my app is in C:\myapp\bin. – Pogel Apr 28 '15 at 07:55
  • I put qt.conf [Paths] Prefix = $(myapp_HOME)\common Plugins = $(myapp_HOME)\common – Pogel Apr 28 '15 at 07:56
  • in same directory as my executable without success – Pogel Apr 28 '15 at 08:00
  • It won't work under Windows. Everything (the executable and dll files) have to be in the same directory. Sorry. That's how it works under Windows. Here a more detailed description of this subject: http://stackoverflow.com/questions/2463243/dll-search-on-windows – Googie Apr 28 '15 at 08:23
  • but it worked, you just insert the Path correctly. I forgot to input my last thing to say. Please expand the key "Path" environment variable: C: \ myapp \ common \ bin; C: \ myapp \ common \ plugins; – Pogel Apr 29 '15 at 09:27
  • If it worked it's only because you have your Qt installed in the path that is recognizable by your operating system and it allows your application to use it. The `qt.conf` file alone won't let your application even start, because to read this file, the application has to be already running and it won't start until required DLL files are loaded. This file is used only to make your application aware from which Qt installation should it load Qt plugins (and translations, etc) dynamically, when it already started. – Googie Apr 29 '15 at 10:09
  • C:\myApp_Folder Bin_Folder: Myapp.exe Common_Folder: Bin_Folder: All required dlls Plugins_folder Platforms: Imageformats: Iconengines: QtQuick QtQuick.2 – Pogel Apr 29 '15 at 10:43
  • Are you linking Qt statically to your application? – Googie Apr 29 '15 at 13:16
  • No Dynamic, my application is only 1.6MB size, I think I'm doing here an example so you can check whether you have also runs or not. do you have a Windows computer? when yes i send you a folder (c:\myapp\bin) with my app 1.6Mb and a folder( c:\myapp\common\bin + c:\myapp\common\plugins) with Qt dlls 96MB. You can access my app from any folder, – Pogel Apr 29 '15 at 21:41
  • Yes, I do have Windows machine. Please share it somewhere (DropBox?) and I will try to run it. – Googie May 01 '15 at 11:38
  • you find it at: https://95.222.18.63/nas/filelink.lua?id=012fd45d78e167ce Please add to your path: "Path" environment variable: C: \ MYAPP \ common \ bin; C: \ MYAPP \ common \ plugins; and add variable: MYAPP_HOME value C:\MYAPP – Pogel May 03 '15 at 09:22
  • you can run animatedtiles.exe from any folders – Pogel May 03 '15 at 09:31
  • please see how i add path in my windows machine: https://95.222.18.63/nas/filelink.lua?id=e58cc59a64700ebb – Pogel May 03 '15 at 09:35
  • I'm unable to run it in any way. Nevertheless, I see that your application depends on setting the System PATH variable. That is not correct way of deploying application. You should stick to the standard described in Qt docs: http://doc.qt.io/qt-5/windows-deployment.html#creating-the-application-package There is nothing more I can help you with. Just do it like Qt docs says to do. – Googie May 03 '15 at 21:59