5

I was working on Qt Creator compiler to make a simple text editor. I did that but now want to make an .exe file of that project, but I don't know how to make an .exe file in Qt Creator compiler. Can anyone help?

John Percival Hackworth
  • 11,395
  • 2
  • 29
  • 38
Sarwan Ali
  • 151
  • 1
  • 1
  • 11

5 Answers5

12

There is a tool that adds the .dlls automatically on windows.

In the command prompt navigate to your qt bin directory. It should look something like this: ...\Qt\5.9.1\msvc2017_64\bin\ (I'm using visual studio).

Run windeployqt.exe in the command prompt with your project location as the argument like this:

windeployqt.exe C:\project_folder\my_project.exe

Now my_project.exe will have the .dlls in the same directory and will execute.

Andrew T
  • 184
  • 1
  • 7
8

The executable is generated by the compiler when you build your application. To know where the executable is stored, look into

Projects (CTRL+5) -> Build settings -> General -> Build directory

This is where Qt creator will put the .exe it generates if you have shadow build enabled. If shadow build is disabled, the executable will be stored inside the project folder itself.

zeFrenchy
  • 6,541
  • 1
  • 27
  • 36
5

From: How to create executable file for a Qt Application? Basically you have to look for MinGW subfolder deep into Qt tree, where Qt utilities reside, and copy needed dll's.

These are the steps I follow, based upon Qt 4.7.4, for packaging the application with correct shared libraries.

Let's say you've installed Qt under c:\qtsdk. Open your project, and compile it in release mode. Go to this directory: C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin -- it contains all shared libraries. Debug libraries end with a "d" -- frex, QtCore.dll is release version, while QtCoreD.dll is debug version. Copy at least these files into your release directory (where your .exe lies):

  • mingwm10.dll
  • libgcc_s_dw2-1.dll
  • QtCore4.dll
  • QtGui4.dll

I just built, tested and deployed a dummy project this way.

Community
  • 1
  • 1
Forcetti
  • 486
  • 6
  • 13
0

I had the same problem so I used the suggested above answer: " There is a tool that adds the .dlls automatically on windows.

In the command prompt navigate to your qt bin directory. It should look something like this: ...\Qt\5.9.1\msvc2017_64\bin\ (I'm using visual studio).

Run windeployqt.exe in the command prompt with your project location as the argument like this:

windeployqt.exe C:\project_folder\my_project.exe

Now my_project.exe will have the .dlls in the same directory and will execute. " but there somethings that I did so this might help:

there is already an executable version of your app in the debug file of your project if you can't find it try to enter properties in Qt creator an track down the file. while you are at it in properties you can also see whether your app is using msvc2017_64 like in the previous answer or other compilers.

Take that file to the same path you write in the command line here: windeployqt.exe C:\project_folder\my_project.exe.

when your try to open the executable file it will till it needs some dlls files that you can find in this path .\Qt\5.9.1\msvc2017_64\bin copy and paste them in the location of the exe file

0

Steps to make an exe file from your qt project

  1. In Build Settings make sure Edit build configuration is Release.

  2. In Build Settings uncheck Shadow build(this will make sure that the release folder is inside of your project directory instead of outside of your project directory).

  3. Build and run you project(This will create a release directory inside of yours project folder).

  4. Copy *.dll and *.exe file from C:\Qt\6.3.2\mingw_64\bin to the release folder (where your projects exe file is there).

  5. Copy all folders from C:\Qt\6.3.2\mingw_64\plugins to the release folder.

  6. Now you can launch the exe file inside of your release folder corresponding to your project.

qt settings

Udesh
  • 2,415
  • 2
  • 22
  • 32