Juliette Marquis
Juliette Marquis

Reputation: 199

How to release a Qt/C++ application on Linux and Windows?

I developped an application in C++ using Qt for the graphic interface and now I would like to release it for linux and for Windows. I've been looking through documentation, forums and tutorials but I can't really understand what need to be done...

I'm pretty confused between the different terms used : what is the difference between releasing and deploying ? when do you need an installer and if needed, how to create one ?

What are the different steps to create the .exe of Windows ? and its equivalent for the different versions of Linux (Debian, Ubuntu, Ubuntu Mate)?

I am currently on Ubuntu and used Qt Creator to code the application.

As far as I know, I need to deploy Shared Libraries.

Any help, answer, guide or documentation for beginner would be of great help and very welcome :)

Upvotes: 6

Views: 15879

Answers (3)

mjyazdani
mjyazdani

Reputation: 2035

Another approach is:

  1. Open your project in Qt.

  2. Select projects from left.

  3. In Buils Steps select Add Build Step

  4. Complete the form as below:

    Command: C:\Qt\Qt5.12.12\5.12.12\mingw73_64\bin\windeployqt.exe

    Argument: C:\path\to\your\project\release\folder\yourapp.exe

Example: consider the projet name is TestApp and its address is C:\TestApp. The argument should be like:

C:\build-TestApp-Desktop_Qt_5_12_12_MinGW_64_bit-release\release\TestApp.exe

Wrking Directory: %{buildDir}

Doing this way, every time that you build your project, related libraries would be copied to your release folder.

Upvotes: 0

Michael Schm.
Michael Schm.

Reputation: 2534

There are several ways to deploy your application

1. Deploy your application with windeployqt/linuxdeployqt

This is the easiest way, windeployqt or linuxdeployqt is an application that will copy all required dependencies to your executable folder. Ready to run on another computer.

The steps are simple:

  1. Compile your binary in release mode
  2. Open the Qt developer console and type windeployqt "C:\folder\of\your\executable" (linuxdeployqt will be very similar)
  3. All libraries required to run the application on another computer are copied to to your application folder. You can create an archive and send it to someone else.

Note: linuxdeployqt is third-party.

2. Static build

Static build will be a single binary at the end that includes all Qt code. You can ship your single binary to someone, no additional libraries are required to run it. The executable is larger since all the Qt code is linked inside your executable.

The steps are as following:

  1. Download the Qt source code
  2. Unzip it to a folder
  3. Open the developer console of your installed compiler (i. e. MingW or MSVC)
  4. Switch to the folder and type

    ./configure -static -static-runtime

  5. When the configuration is done type nmake or make to build Qt statically.
  6. When the build process has finished create a new kit in Qt Creator and select the new qmake.exe or qmake from your source-code folder.
  7. Select in the project settings your kit to build a statically executable that requires not additional libraries.

3. Offline/Online Installer

This step requires some reading and fine tuning. Qt comes with an IFW (Installer Framework) where you can create online and offline installers. The installer will contain a .7z file of your executable and all dependencies. The installer is more comfortable for the user. It can create shortcuts, check available disk space, etc.

IIRC you need build the installer statically for MSVC or you have to ship the runtime libraries. If build with MingW you probably will not need any runtime libraries.

It is up to you which method you choose. If you own the commerical license you can ship all your closed source as static builds, but in general it's better to ship it as a dynamic build especially if you use OpenSSL where users can quickly exchange vulnerable libraries themself if required.

Upvotes: 8

As far as I know, I need to deploy Shared Libraries.

Probably not. First, notice that you don't release for Linux (in general), but for a particular Linux distribution. Details matter and are different on Ubuntu 15, Ubuntu 16, Debian 9, Fedora ... etc.

(I guess it could be the same on Windows: the version of Windows could matter, so Windows 7 not the same as Windows 10)

You should prefer to use the installed Qt on the target Linux distribution (its minor version would be different from one distro to another).

You probably want to make a software package, for the package manager of your target Linux distribution. On Debian or Ubuntu, that would be some .deb package.

(you can't be sure that your .deb for Ubuntu would work for Debian, but that is usually the case)

A package manager handles dependencies. So if your user would install a correct .deb provided by you, the package manager would either fail or (more often) download and install all the required dependencies (e.g. Qt).

(Or you could distribute the source code - perhaps as free software -, and leave the task of compiling it to your users or to distribution makers)

How to make a Linux package is well documented by the particular distribution you are targetting, and is a different question. For Debian see here.

Upvotes: 0

Related Questions