Как сделать exe файл в qt creator

от admin

How to make .exe file in Qt Creator

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?

Sarwan Pasha's user avatar

5 Answers 5

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:

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

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's user avatar

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.

Forcetti's user avatar

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:

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

Build Standalone Qt Application for Windows

The goal of this article is to show how to build a standalone executable file of a Qt application for Microsoft Windows. This is an executable file that has no dependencies (aka does not require any dynamic linking to libraries). To create such a standalone version of a Qt application all required libraries should be embedded into the application using static linking. Please note that the size of the executable file will be larger.

Build a static version of Qt

The first step is to build a static version of Qt. The commands that should be executed depend on the desired platform MinGW (win32-g++) or Microsoft Visual Studio (win32-msvc).

Using MinGW

More information on static builds with mingw can be found here

Using Microsoft Visual Studio

Make sure that Microsoft Visual Studio is installed. Start the Visual Studio 2008 Command Prompt. Otherwise you may get errors due to wrong or missing paths. Execute the following commands in the directory where Qt is installed (for example: C:\6.3\):

Читать:
Как сделать чтобы не лагала дота

Please note that reconfiguring and building Qt is a time consuming procedure. The duration may vary depending on the hardware of your computer.

Build a static application

Modify the .pro file of the project by adding an option for static linking. CONFIG+= static

Using MinGW

To build the application run consecutively qmake and mingw32-make.

Using Microsoft Tools

To build the Qt project as a standalone executable file run qmake and nmake. After that you should execute mt.exe to embed a manifest inside the application to avoid error such as missing MSVCP90.dll when the application is started on other computers.

Please note that the names of the manifest and the executable file depend on the name of your project.

Как сделать .exe файл в Qt Creator

Я работал над компилятором Qt Creator, чтобы создать простой текстовый редактор. Я сделал это, но теперь хочу сделать .exe файл этого проекта, но я не знаю, как сделать файл .exe в компиляторе Qt Creator. Может ли кто-нибудь помочь?

3 ответа

From: Как создать исполняемый файл для приложения Qt? В основном вам нужно искать подпапку MinGW глубоко в Qt-дерево, где утилиты Qt находятся и копируют необходимые DLL файлы.

Ниже приведены шаги, которые я следую на основе Qt 4.7.4, для упаковки приложения с использованием правильных разделяемых библиотек.

Скажем, вы установили Qt под c:\qtsdk. Откройте свой проект и скомпилируйте его в режиме выпуска. Перейдите в этот каталог: C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin — он содержит все разделяемые библиотеки. Отладочные библиотеки заканчиваются на «d» — frex, QtCore.dll — это версия выпуска, а QtCoreD.dll — отладочная версия. Скопируйте хотя бы эти файлы в каталог выпуска (где находится ваш.exe):

  • MINGWM10.DLL
  • libgcc_s_dw2-1.dll
  • QtCore4.dll
  • qtgui4.dll

Я только что построил, протестировал и развернул фиктивный проект таким образом.

Исполняемый файл генерируется компилятором при создании приложения. Чтобы узнать, где хранится исполняемый файл, загляните в

Projects (CTRL+5) → Build settings → General → Build directory

Это то, где создатель Qt поставит.exe, который он генерирует, если у вас включена функция shadow build. Если теневая сборка отключена, исполняемый файл будет храниться внутри самой папки проекта.

Как сделать .exe файл в Qt Creator

Я работал над компилятором Qt Creator, чтобы сделать простой текстовый редактор. Я сделал это, но теперь хочу сделать .exe файл этого проекта, но я не знаю, как сделать .exe файл в компиляторе Qt Creator. Кто-нибудь может помочь?

Решение

Исполняемый файл генерируется компилятором при сборке приложения. Чтобы узнать, где хранится исполняемый файл, посмотрите в

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

Именно здесь создатель Qt поместит .exe, который он генерирует, если у вас включена теневая сборка.
Если теневая сборка отключена, исполняемый файл будет храниться в самой папке проекта.

Другие решения

От:
Как создать исполняемый файл для приложения Qt?
По сути, вы должны искать подпапку MinGW глубоко в дереве Qt, где находятся утилиты Qt, и копировать необходимые библиотеки DLL.

Это шаги, которые я следую, основанные на Qt 4.7.4, для упаковки приложения с правильными общими библиотеками.

Допустим, вы установили Qt в c: \ qtsdk.
Откройте ваш проект и скомпилируйте его в режиме релиза.
Перейдите в этот каталог: C: \ QtSDK \ Desktop \ Qt \ 4.7.4 \ mingw \ bin — он содержит все общие библиотеки. Библиотеки отладки заканчиваются на «d» — frex, QtCore.dll — версия выпуска, в то время как QtCoreD.dll — версия отладки.
Скопируйте хотя бы эти файлы в каталог выпуска (где лежит ваш .exe):

  • MINGWM10.DLL
  • libgcc_s_dw2-1.dll
  • QtCore4.dll
  • qtgui4.dll

Я просто создал, протестировал и развернул фиктивный проект таким образом.

Существует инструмент, который автоматически добавляет DLL-файлы в Windows.

В командной строке перейдите в каталог qt bin. Это должно выглядеть примерно так: … \ Qt \ 5.9.1 \ msvc2017_64 \ bin \ (я использую visual studio).

Похожие статьи