Having trouble building Qt program - c++

I created a Qt GUI application and I am trying to package it to share with other people. I built the package and used Dependency Walker to find all of the .dll files that I needed to include. After I put them all in the same directory as the .exe; I launched the .exe for the program and I got a message that another .dll was missing I included it. I was asked in the same way to add two more .dll files. After all the .dll's were included I launched the .exe and got this weird message.
I consulted Qt 5.0.2 documentation and I couldn't find any help. It works fine when I run it within Qt Creator.
I don't know what to do from here but any help would be great

Some things you could do to find out the problem:
Check if it behave the same way in debug and release mode. Note that the two modes need different DLLs.
Check if you are using the correct versions of the DLLs. If you installed different versions of Qt or other dependencies than there could be conflicts around DLLs that are the same but from different versions. Maybe you are in a kind of DLL Hell.
You should copy your program to another PC that doesn't have Qt installed. And watch if it works properly.

Related

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)

Qt-Application Deployment doesn't work. Missing entry point and dll's

In the last months I created a project with the Qt-Creator version 4.7.0, Qt version 5.11.1 (open source version).
Now I tried to deploy it following the Qt doc and building the project with MSVC2017-64bit compiler as well as running windeployqt.exe afterwards on the generated executable.
As I tried to run the executable after the programm finished copying the neccessary dlls into the folder, a warning appeared:
The entry point ?
eventFilter#QAbstractItemView##MEAA_NPEAVQObject##PEAVQEvent###Z wasn't found in DLL "my/project/path/releasefolder/project.exe".
It seems to me like something was wrong with the Qt-Objects I use in my project, but I couldn't find anything, as it still worked flawlessly in the Qt-Creator.
A thought it might be due to the compiler having issues, so I changed it to mingw32, which I also tried to deploy the same way. But somehow in this case the warning disappeared, but many dlls were still missing even though windeployqt.exe should've already done that. And I also couldn't find them anywhere on my hard drive. I also tried a third compiler, but the issues weren't going away.
I searched online and only found people having problems with an entry point missing in a Qt dll or missing the Qt-Dlls in general, but haven't found anything related to my case.
I also tried Dependency Walker on every executable, but it found even more missing dll, which led me to believe the executables were somehow currupted so I tried it again and again, but with no success unfortunately.
Has someone any idea, why that could happen, or any suggestion for me?
Maybe I should change something in my project, even though it works fine in the IDE. I just need a way to deploy my Qt project in any way.
EDIT: Build using the Desktop Kit in Qt Creator with MSVC2017 the described warning appeared.
Build with Mingw32 (Desktop Kit) and with MSVC2017 using the UWP Kit in Qt Creator the following Dll was missing, that I haven't found anywhere on my hard drive: MSVCP140_APP.dll
EDIT2: I ended up downloading the required dll, to somehow get it to work, but it still didn't work. One build, that required that dll now started but immediately closes itself again and the other build was suddenly warning me of a missing procedure entry point.
EDIT [SOLUTION]: I let the Qt Creator create a whole new fresh project and copied all files from my old project in the new one. After that I only copied all the dll files into the folder and it worked.
Instead of relying on windeploy, manually add the dll. I am assuming you have built the project using mingw. Assuming you are using Qt 5.11.1, go to
C:\Qt\Qt5.11.1\5.11.1\\bin\ and copy all the dll files and paste in your executable folder. Also copy all directories from plugins folder (in /plugins) and paste in your folder. Now run the application, don't close the application. Now delete all the files from your executable folder. The one's not being used are deleted and the rest are left. I assume you are doing this on target computer. This might help.

Error when launching application

I have rebuilt the QGIS code on VC2008 on Windows 7.
I have all the correct DLLs in the folder of the exe, and can see that it knows where the QT DLLs are.
When I launch the app, I get this error:
The procedure entry point ??4QPixmap##QAEAAV0#$$QAV0##Z could not be
located in the dynamic link library QtGui4.dll
I'm not sure where to start to get this working. I checked the QtGUI4.dll to see that it is loading, with a dummy app. It seems fine.
Any help would be great.
Posting it as an answer since my hunch turned out correct:
This error shows that your application was loading the wrong Qt DLLs. For whatever reason, it was finding and loading DLLs different from the DLLs against which it was built. In your case it turned out it was finding Qt4 built for VS2010 DLLs, while it needed Qt4 built for VS2008.
The solution is to make sure it always finds the correct DLLs - place the correct DLLs in the EXE's folder, as this is usually the first place it looks for for DLLs. On Windows, it's not a good idea to rely on %PATH% or on the current directory.

My app 'Qt' runs in my computer but does not run on my friend's

I have a problem as I mentioned in the title, when I run it in my computer it's totally fine even if I moved the .exe file to another folder, but it cannot be run in my friend's, I tried to build it using 64bit and 86bit but still the same problem.
This is the error:
the application was unable to start correctly 0xc00007b
I've searched and found that it's because of the .dlls but how can I know which dll?
Edit: answering the question:
I'm using Qt 5.1.1 I built it statically , and my compiler is msvc11 86x.
problem:: Edit:
after assuming that my friend's windows has some problems since he really does have some problems , I installed a virtual one using virtualbox " windows 7 32bit " when I moved my app it really asked for msvcp110.dll and msvcr110.dll , but after downloading them from a website now it says:
the procedure entry point _crt create symbolic link w could not be
located in the dynamic link library msvcr110.dll
not sure should the files be from my windows or it's ok to download it from websites like dlls-files ?
Edit 3:
I solved it after deleting all the msvc dlls that I've downloaded manually when it asked , and I updated the windows and installed every version of the things that you guys listed and it works , but you need to delete the files that you've downloaded first otherwise it won't work.
thanks for all your help.
If you are dynamically linking to Qt, you should place Qt DLLs along the release version of your executable. These are Qt5Core.dll, Qt5Gui.dll and possibly the ones for other modules that you have used. These dll files are in your installed Qt Directory in bin folder.
You should also place msvcr110.dll and msvcp110.dll in case you are using MSVS2011. If you are using plugins you should place their dll in a folder named plugins beside your exe. In case of using icons and images you should ship their dlls like qico.dll and qsvg.dll in a folder named imageformats.

Packaging libraries with .exe

I've made an application using both the OpenCV and WxWidgets library. The code runs fine on my development machine.
However, when I transfer it to another windows machine I get the error
*"The program can't start because cv110.dll is missing from your computer.
Try reinstalling the program to fix this problem".*
Now, I'm guessing installing the same versions of OpenCV and WxWidgets as used in development would resolve this problem but this is a bit much to ask of a casual 3rd party user of my code.
In my IDE (Windows Visual C++ 2008) I've linked to the relevant .lib files by going to Properties->Linker->Input
How would I go about packaging the .exe so that it works on non-development machines?
i.e. if I include the .dll files, how would I need to change the linker configuration to reflect this ? Or, can the .dll files referenced by the .lib files be incorporated into the .exe ?
Sorry, I know this issue has come up before but I can't seem to find a resolution specific to my case. Any help would be appreciated!
OpenCV is built using dynamic libraries
The correct thing to do is create an installer containing your exe and the correct dlls you need. See https://stackoverflow.com/questions/1285591/installer-recommendation