Manual Install of Qt6 on Linux Mint

The next major version of Qt6 was released about two weeks ago, and I wondered how to get it to run on Linux. It is pretty simple on Windows because almost everything is based on an installer, and so the Qt installer fits in nicely. On Linux, however, where everything is package-manager based, how would you go about it there?

Let me show you how I did it.

Out of curiosity, I started by looking at what the apt package manager thinks about Qt6. For reference, I searched for "qt5" to get a baseline on how it should look.

Now, the same thing with "qt6".

As I expected, Qt6 is not yet part of the package repository. That means, to install it, you need to download the official Qt installer and do what every Windows user does 😅 Or you can grab the sources and compile it yourself, just out of spite.

So, go to "https://www.qt.io/download-open-source" and download the installer. I have linked to the Open Source variant, so be mindful of the requirements that come with it. But, since this is about Linux, I am sure you are aware of what that means.

Installation

Before you can start the installer, you must set the execute-bit. I ran it as a superuser because I wanted to install it to /opt. If you are happy with the applications and libraries to be located in your user directory, feel free to do so and omit sudo.

chmod +x qt-unified-linux-x64-4.0.1-online.run
sudo ./qt-unified-linux-x64-4.0.1-online.run

There are two unfortunate things you will notice when the installer comes up:

  1. It looks like a terrible "gamer software" with a green accent color instead of the more typical red. I hate that, and if anyone from the Qt Company ever stumbles across this blog post, please change it and use more of the native look and feel of the host OS. It is okay to have some corporate branding, like the buttons, for example, so they match the website’s look. But your website isn’t all green, now is it?
  2. You must create a Qt Account to install the framework. That is a bummer, and it has already driven me crazy in a previous version of the installer on Windows. Once the anger passes, create the account and be done with it. Or wait for the package manager to support it or maybe get the sources and compile yourself. I do not know if downloading the sources requires such an account, though.

The next two images show the location where I installed the Qt 6 stuff (the reason for sudo) and what packages and tools I selected. You can go all-out and install everything there is, or start minimalistic like I did and add more features over time when you need them.

By default, Cmake and Ninja are selected. I deselected these options and installed the necessary tools myself using the apt package manager. If possible, I prefer that over a custom installer.

sudo apt install cmake cmake-qt-gui ninja-build openssl

Continue through the wizard, and after downloading and unpacking a bunch of stuff, you are good to go. Now that you have installed Qt 6, there are a few more things to know and tweak to make the framework more convenient to use.

Panel Shortcut (*.desktop)

If you already have Qt Creator installed through the package manager, you can edit that file or copy it and use it as a basis for your own. I created a copy since I thought I do not want the package manager to update the file it created or remove it when I make changes to the Qt 5 installation.

sudo cp /usr/share/applications/org.qt-project.qtcreator.desktop /usr/share/applications/qtcreator.desktop
sudo vim /usr/share/applications/qtcreator.desktop

The only things I changed are "Exec" and "Name".

[Desktop Entry]
Type=Application
Exec=/opt/Qt/Tools/QtCreator/bin/qtcreator %F
Name=Qt Creator (/opt)
GenericName=C++ IDE for developing Qt applications
X-KDE-StartupNotify=true
Icon=/opt/Qt/6.0.0/Src/qtdoc/doc/src/images/qt-logo.png
StartupWMClass=qtcreator
Terminal=false
Categories=Development;IDE;Qt;
MimeType= text/x-c++src;text/x-c++hdr;text/x-xsrc;application/x-designer;application/vnd.qt.qmakeprofile;application/vnd.qt.xml.resource;

Usage

If you run qmake from the command line, you either get an error or the version installed by your package manager. There are a few ways to work around this:

  1. export PATH=/opt/Qt/6.0.0/gcc_64/bin/:$PATH
  2. Modify the qtchooser configuration file: https://askubuntu.com/a/436539
  3. Create a symlink to the Qt 6 qmake binary, ln -s /opt/Qt/6.0.0/gcc_64/bin/qmake /usr/bin/qmake. I have one called /usr/bin/qmake6. You can also name it /usr/bin/qmake, but I wanted to avoid potential issues with the package manger "fixing" this back to the Qt 5 version.

CMake

Qt 6 recommends using the CMake build tool in favor of Qt’s stalwart qmake utility. If you plan only to use Qt Creator then you are all set. It does all the necessary configuration for you. However, if you run CMake from the command line, you will likely encounter this error.

-- The CXX compiler identification is GNU 9.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:14 (find_package):
Could not find a package configuration file provided by "QT" with any of
the following names:

    Qt6Config.cmake
    qt6-config.cmake

Add the installation prefix of "QT" to CMAKE_PREFIX_PATH or set "QT_DIR" to
a directory containing one of the above files.  If "QT" provides a separate
development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred! 

I remember it fondly from a little issue I ran into on Windows a short while ago. The fix is simple:

export CMAKE_PREFIX_PATH=/opt/Qt/6.0.0/gcc_64/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.