QT 5 Creator INclude required DLL's in Executable - c++

I have created a simple file copy program that I would like to run as a stand alone executable.
However when I run it outside Qtcreator I get a Qt5Core.dll is not found error.
I have found some stuff about copying the dll to the same folder as the executable or compiling staticly, but I have had no luck with this.
Is there a way to embed all the required dll's n the executable?
Preferably with the .pro file
Thanks,

Related

Qt Creator can't find library files in the search path

When I compile the release target, everything is built correctly and I can run the program via windows explorer (the install script copies all the libraries to the .exe folder).
The problem that I am having, is that the program does not run inside QtCreator (in both debug and release) unless I manually copy the libraries to the .exe folder. This was not how it used to work but somehow, since I upgraded to Qt6 and start to use mingw instead of vc++, this behaviour started to happen.
There is an option in the project tab to "Add build library search to the PATH" that apparently is intended for exactly this reason (sip copying the libraries every time we compile), but somehow this is not working. I see the PATH change in the Environment form, but the program just crashes on loading with a "This application was unable to start correctly". If I copy the libraries and try again, it works.
So it turns out that it can't find just the onnxruntime.dll library. I assume that it has trouble finding any library that does not start with lib from the path. My solution for now was to copy just this file to the .exe folder.

Qt C++ Missing DLLs

I created a simple notepad file using Qt.
The program does run when in Qt creator.
However, when I navigate to the debug folder, the created executable file does not run without DLLs.
I've read online that this is can happen and all that is required is that the respective DLLs be copied to the location of the exe file. However... the error messages identify DLLs that my machine does not have.
I get and error message for the following DLL files.
Qt5Cored.dll, Qt5Widgetsd.dll, QtPrintSupportd.dll
I do not have the DLLs above. I do however have the dll files below. Which do not have the added 'd' before the extension.
Qt5Core.dll, Qt5Widgets.dll, QtPrintSupport.dll
Any help provided would be much appreciated.
Thank you in advance!
First i can't think of any reason you would want to copy (preparing for an installer) the dependencies for the debug build of your application, the debug is not a build that you want to deploy, use the release build for deployment.
Now, that being said, you definitely have the dll's, otherwise your debug build won't run from Qt Creator, you are just not looking in the right path for those dlls.
The path where you find the dll is something like: C:\Qt\5.12.3\msvc2017_64\bin
notice that there can be many Qt versions installed and for different targets (example android), so the right way to find the dlls is: QT_INSTALL_PATH / QT_VERSION / COMPILER_VERSION _ARCHITECTURE / bin, so the sample path i provided is Qt version 5.12.3 build with Visual Studio 2017's compiler and it is a 64 bit build. In that path you will find the right dlls: Qt5Core.dll (the release build), Qt5Cored.dll (debug) and so on for all the Qt modules.
Side note: you most likely looked into the folder where Qt Creator .exe is located, there you will find only the Qt dlls that are needed for Qt Creator to work, you are not supposed to use those dlls to deploy your application (those might be built with a different compiler than what you are using and even cause crashes for your application, because of incompatible abi)

Export executable program from QtCreator

I want to export an executable program from Qtcreator, the program works fine inside the Qtcreator but outside I got an error message, "missing QT5CORED.DLL" so I add it to the binary file but it keeps asking for other dependencies.
You need to put that dll in the executable folder. The dll would be in the Qt folder i assume, check it.
Also please note that is a debug dll (the last D in the name), you‘d want to ship a release build instead of a debug one.
You can find necessary QT dll's in: QT Directory \mingw48_32\bin
and windows runtime dll's in: QT Directory \mingw48_32\plugins\platforms
path is for mingw compiler

failed to load platform plugin "windows" Available platforms are: windows, minimal

Hi Im trying to execute my .exe file from the debug folder.
Now before you go telling me about all the other related articles Ive looked at them all and their solutions are not helping with my problem.
Ok first off Im using Qwt library and trying to create a set of gauges. I got a gauge working now I need to get it to execute from the .exe.
Ive tried adding the platforms folder in with my directory and adding the windowsd.dll and minimald.dll but still does not work.
Please advise on any course of action this had got me stumped.
Also one post says to create a qt.conf file and place it in the directory but I cant find out how to make a .conf file.
UPDATE
the error reads
debug error!
Program:
...build-Desktop_Qt_5_0_1_MSVC2010_32bit-Debug\debug\gauge.exe
Module:5.0.1
File: kernel\qguiapplication.cpp
Line:781
Failed to load platform plugin "windows". Available platforms are:
minimal
Windows
When deploying Qt on Windows, you have to copy over a number of the dlls from the bin folder of the Qt directory.
On my system it is:
C:\Qt\4.8.4\bin
After you copy over all the required dll's from there, like QtCore4.dll and QtGui4.dll, if you are using any additional plugins like phonon or jpeg support, you need to copy those dll's over from the plugins folder:
C:\Qt\4.8.4\plugins
For example I make a folder in the folder with my exe called imageformats and I put qjpeg4.dll in that folder.
As far as Qwt works, you probably need to do a similar process to expose those dll's to your exe, and put them in the same folder as your exe.
The dll's listed above are for the "release" build of your exe. If you are running the "debug" version, it will look for <dll_name>d.dll.
The reasoning for putting in those paths has to do with the library search order that windows uses.
Qt, Phonon and multimedia codecs: how to bundle them?
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx
http://qt-project.org/doc/qt-4.8/deployment-windows.html#creating-the-application-package
Hope that helps.
If you have several executable and\or you don't want to copy plugins by hand, you can create a qt.conf file with the path to the plugin directory
[Paths]
Plugins = PATH_TO_QT_DIR/plugins
You need to place the qt.conf file where the executable is.
More information at http://doc.qt.io/qt-5/qt-conf.html

Qt - Get rid from .dll file missing errors

I have created a GUI which requires .dll files in order to work. Here the list of those:
mingwm10.dll libgcc_s_dw2-1.dll
QtCore4.dll QtGui4.dll
I have read that I should write
CONFIG += static
in .pro file. But it does not work. Could you help?
You need a Qt installation that is built for static-linking for that CONFIG statement to work. The only way to gt a static Qt install is to download the source package and built it yourself.
Now, to deploy your dynamically linked Qt app, just copy those DLL files to the same folder as your built exe file. This may be easier than building Qt statically.