How to Create a Qt Project Executable | Missing Files Fix
Table of contents
- Step 1: Switch from Debug Mode to Release Mode
- Step 2: Enter the release folder
- Step 3: Delete all Files except the .exe file in the "release" folder you are currently in.
- Step 4: Open MinGW
- Step 5: Set the directory location of the .exe file
- Step 6: Build the necessary files in the directory location
- MISSING .DLL FILES POTENTIAL FIX
So you've built your Qt project application and want to share the executable file for others to run without having them install Qt on their computer. The process to do this is simple and I include a fix for a "missing.dll files" issue that may arise. With that said, let's begin...
NOTE: I am using a Windows 10 laptop running Qt 6.3.0.
If you want to skip reading, here is a video I found on YouTube that shows this entire process, as well as how to create an installer for your project:
Video link: https://youtu.be/hCXAgB6y8eA
Step 1: Switch from Debug Mode to Release Mode
After opening a project, above the run arrow button, there should be another that reads "Debug" with a PC image placeholder. Upon clicking it, you'll see the project details with options to switch to Profile and Release. Click on Release and then click the run button. In your project folder, you should see another folder named similarly to the build folder except it will have the word "Release" at the end of its name instead of "Debug".
Step 2: Enter the release folder
In your project folder, enter the "Release" folder that was just built and enter the directory named "release" - note the naming of these folders. Your directory location should look like what I have in the picture below.
Step 3: Delete all Files except the .exe file in the "release" folder you are currently in.
It should be named "yourprojectname.exe". You may also skip deleting these files and simply copy the .exe file to another directory location where you would like to have this project's necessary files built (like in a folder in the documents/desktop etc.).
NOTE: Replace yourprojectname with your own project name.
Step 4: Open MinGW
Find the MinGW app that corresponds with the compiler you are using for your project. As seen below, I am using Qt 6.3.0 (MinGW 11.2.0 64-bit).
Step 5: Set the directory location of the .exe file
Copy the directory location of your .exe file. In MinGW, type cd and space right after. Then, paste the directory location you copied and press Enter.
Step 6: Build the necessary files in the directory location
Type "windeployqt yourprojectname.exe" in MinGW and press Enter. Next, just simply wait until the process is done. After it is done, you may run the .exe file of your project. If you plan to share it around, ZIP the folder that holds the executable. The executable will only work if it is in the folder with the rest of the files that were built.
The below picture shows an example of what you should have in MinGW.
The below picture shows the files that were built alongside your executable file.
MISSING .DLL FILES POTENTIAL FIX
If you do not have any of the files in the red brackets seen in the picture below, you can download them from my google drive using the links below the picture and move them to the folder with your executable.
File 1 (libgcc_s_seh-1.dll): https://drive.google.com/file/d/1grJgWoeKdPDnho3QrGR8QVBNM5q-e_kN/view?usp=sharing
File 2 (libstdc++-6.dll): https://drive.google.com/file/d/151OPL8JeyAq9j7RfKKWXtmP8DkqmC3O2/view?usp=sharing
File 3 (libwinpthread-1.dll): https://drive.google.com/file/d/1ETaBY4KViQARzd4Mui2DFAFv0NJYaInw/view?usp=sharing
If you have more .dll files missing then you may need to do some further research. Dependency Walker was brought to my attention by one of my classmates and it was mentioned to be able to know and include all files necessary to run the executable. I have not tried this method before so I cannot tell if works.
Thank you for reading and I hope this helps.
Subscribe to my newsletter
Read articles from Tadeo Bennett directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Tadeo Bennett
Tadeo Bennett
I am an aspiring software engineer from the University of Belize, currently pursuing a Bachelor's degree in computer science. I am diving headfirst into the endeavor of writing and focused reading. Therefore, this blog is an outlet to grow those skills while benefiting those who may find my content helpful. I write about topics related to software, development, design, and personal growth from the perspective of an INTJ.