- Qt Documentation
- Contents
- Supported Configurations
- Requirements for Development Host
- Debian/Ubuntu (apt-get)
- Fedora/RHEL/CentOS (yum)
- openSUSE (zypper)
- Building Qt from Source
- Deployment and Other Issues
- Where to Go from Here
- Qt Documentation
- Contents
- Supported Configurations
- Requirements for Development Host
- Debian/Ubuntu (apt-get)
- Fedora/RHEL/CentOS (yum)
- openSUSE (zypper)
- Building Qt 5 from Source
- Deployment and Other Issues
- Where to Go from Here
- Qt Documentation
- Contents
- Platform Plugin Dependencies
- Accessibility Dependencies
- OpenGL Dependencies
- Multimedia Dependencies
- Speech Dependencies
- Qt WebEngine Dependencies
- QDoc Dependencies
- Qt Documentation
- Contents
- Static Linking
- Building Qt Statically
- Linking the Application to the Static Version of Qt
- Shared Libraries
- Building Qt as a Shared Library
- Linking the Application to Qt as a Shared Library
- Creating the Application Package
- Application Dependencies
- Additional Libraries
Qt Documentation
Contents
Qt’s support for different Linux platforms is extensive and mature.
To download and install Qt for Linux, follow the instructions on the Getting Started with Qt page.
Supported Configurations
The following configurations are supported.
Distribution | Architecture | Compiler | Notes |
---|---|---|---|
CentOS Linux 8.1 | x86_64 | GCC 9 | |
openSUSE 15.2 | x86_64 | GCC 9 | |
SUSE Linux Enterprise Server 15 SP2 | x86_64 | GCC 10 | |
Ubuntu 20.04 | x86_64 | GCC as provided by Canonical, GCC 9.x | |
Generic Linux | x86 and x86_64 | GCC 9 |
Requirements for Development Host
The Qt installers for Linux assume that a C++ compiler, debugger, make, and other development tools are provided by the host operating system. In addition, building graphical Qt applications requires OpenGL libraries and headers installed. Most Linux distributions do not install all of these by default, but setting up a development environment is still straightforward.
Use the following commands to install the basic requirements for building Qt applications:
Debian/Ubuntu (apt-get)
Fedora/RHEL/CentOS (yum)
openSUSE (zypper)
Building Qt from Source
You can also build Qt from the source package and configure it according to your target platform. The source packages are obtained from http://www.qt.io/download/.
Below, you will find more information about building Qt from source.
Deployment and Other Issues
The pages below covers specific issues and recommendations for creating Linux/X11 applications.
Where to Go from Here
We invite you to explore the rest of Qt. We prepared overviews which help you decide which APIs to use and our examples demonstrate how to use our API.
- Qt Overviews — list of topics about application development
- Examples and Tutorials — code samples and tutorials
- Qt Reference Pages — a listing of C++ and QML APIs
Qt’s vibrant and active community site, http://qt.io houses a wiki, a forum, and additional learning guides and presentations.
В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Источник
Qt Documentation
Contents
Qt’s support for different Linux platforms is extensive and mature.
To download and install Qt for Linux, follow the instructions on the Getting Started with Qt page.
Supported Configurations
The following configurations are supported.
Distribution | Architecture | Compiler | Notes |
---|---|---|---|
openSUSE 15.1 | x86_64 | GCC 5 or later, GCC 7, ICC 19.1 | |
SUSE Linux Enterprise Server | x86_64 | GCC 5 or later, GCC 10 | |
Red Hat Enterprise Linux 7.6 | x86_64 | GCC 5.3.1 via devtoolset-4 | |
Ubuntu 18.04 | x86_64 | GCC 5 or later, GCC 9 | |
Generic Linux | x86 and x86_64 | GCC (5 or later), ICC 18.x |
Requirements for Development Host
The Qt installers for Linux assume that a C++ compiler, debugger, make, and other development tools are provided by the host operating system. In addition, building graphical Qt applications requires OpenGL libraries and headers installed. Most Linux distributions do not install all of these by default, but setting up a development environment is still straightforward.
Use the following commands to install the basic requirements for building Qt applications:
Debian/Ubuntu (apt-get)
Fedora/RHEL/CentOS (yum)
openSUSE (zypper)
Building Qt 5 from Source
You can also build Qt 5 from the source package and configure it according to your target platform. The source packages are obtained from http://www.qt.io/download/.
Below, you will find more information about building Qt from source.
Deployment and Other Issues
The pages below covers specific issues and recommendations for creating Linux/X11 applications.
Where to Go from Here
We invite you to explore the rest of Qt. We prepared overviews which help you decide which APIs to use and our examples demonstrate how to use our API.
- Qt Overviews — list of topics about application development
- Examples and Tutorials — code samples and tutorials
- Qt Reference Pages — a listing of C++ and QML APIs
- Qt X11 Extras — provides additional APIs for X11
Qt’s vibrant and active community site, http://qt.io houses a wiki, a forum, and additional learning guides and presentations.
В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Источник
Qt Documentation
Contents
Platform Plugin Dependencies
On Linux, the xcb QPA (Qt Platform Abstraction) platform plugin is used. It provides the basic functionality needed by Qt GUI and Qt Widgets to run against X11. Its library dependencies are described the following table. To build Qt from its source code, you will also need to install the development packages for these libraries for your system.
Note: From Qt 5.15 onwards, Qt does require libxcb 1.11. Also, the -qt-xcb configure option got removed that was bundling some of the libs below. Anyhow, you can now configure with -bundled-xcb-xinput to avoid a dependency to system xcb-xinput.
Name | Library | Notes | Configuration options | Minimum working version |
---|---|---|---|---|
XRender | libXrender | X Rendering Extension; used for anti-aliasing and alpha cursor support | -xrender or auto-detected | 0.9.0 |
xcb-render | libxcb-render | X C Bindings for Render extension | auto-detected | 1.9 |
xcb-render-util | libxcb-render-util | Utility library for XCB for Render extension | auto-detected | 0.3.8 |
xcb-shape | libxcb-shape | X C Bindings for Shape extension | auto-detected | 1.9 |
xcb-randr | libxcb-randr | X C Bindings for Resize and Rotate Extension | auto-detected | 1.9 |
xcb-xfixes | libxcb-xfixes | X C Bindings for Fixes Extension | auto-detected | 1.9 |
xcb-sync | libxcb-sync | X C Bindings for Sync Extension | auto-detected | 1.9 |
xcb-shm | libxcb-shm | X C Bindings for Shared Memory Extension | auto-detected | 1.9 |
xcb-icccm | libxcb-icccm | X C Bindings for ICCCM Protocol | auto-detected | 0.3.9 |
xcb-keysyms | libxcb-keysyms | Utility library for XCB for keycode conversion | auto-detected | 0.3.9 |
xcb-image | libxcb-image | Utility library for XCB for XImage and XShmImage, used for QBackingStore and cursor support | auto-detected | 0.3.9 |
xkbcommon | libxkbcommon | Keymap handling | -xkbcommon or auto-detected | 0.5.0 |
xkbcommon-x11 | libxkbcommon-x11 | Keymap handling | auto-detected | 0.5.0 |
Fontconfig | libfontconfig | Font customization and configuration | -fontconfig or auto-detected | 2.6 |
FreeType | libfreetype | Font engine | 2.3.0 | |
Xext | libXext | X Extensions | 6.4.3 | |
X11 | libX11 | X11 client-side library | 6.2.1 | |
xcb | libxcb | X C Binding library | 1.9 | |
X11-xcb | libX11-xcb | Xlib/XCB interface library | 1.3.2 | |
SM | libSM | X Session Management | -sm or auto-detected | 6.0.4 |
ICE | libICE | Inter-Client Exchange | -sm or auto-detected | 6.3.5 |
glib | libglib-2.0 | Common event loop handling | -glib or auto-detected | 2.8.3 |
pthread | libpthread | Multithreading | 2.3.5 |
Development packages for these libraries contain header files that are used when building Qt from its source code. On Debian-based GNU/Linux systems, for example, we recommend that you install the following development packages:
- libfontconfig1-dev
- libfreetype6-dev
- libx11-dev
- libx11-xcb-dev
- libxext-dev
- libxfixes-dev
- libxi-dev
- libxrender-dev
- libxcb1-dev
- libxcb-glx0-dev
- libxcb-keysyms1-dev
- libxcb-image0-dev
- libxcb-shm0-dev
- libxcb-icccm4-dev
- libxcb-sync0-dev
- libxcb-xfixes0-dev
- libxcb-shape0-dev
- libxcb-randr0-dev
- libxcb-render-util0-dev
- libxcd-xinerama-dev
- libxkbcommon-dev
- libxkbcommon-x11-dev
Some of these packages depend on others in this list, so installing one may cause others to be automatically installed. Other distributions may provide system packages with similar names.
Accessibility Dependencies
The Qt accessibility implementation uses the Assistive Technology Service Provider Interface (AT-SPI). Besides DBUS, the development package libatspi2.0-dev must be installed.
OpenGL Dependencies
Configure attempts to automatically detect OpenGL ES 2.0, or later, or regular desktop OpenGL. You can disable OpenGL support by using the -no-opengl option.
Note: The Qt OpenGL module (which contains classes that start with QGL) has been deprecated in favor of the Qt GUI module (which contains classes that start with QOpenGL).
Multimedia Dependencies
As described in the Multimedia overview, Qt Multimedia uses the GStreamer multimedia framework as the backend for audio and video playback on Linux. The minimum required version of GStreamer is 0.10.24. The 1.x series is also supported.
To build Qt Multimedia, you need the GStreamer library, base plugins, and development files for your system. To run applications that use Qt Multimedia, you might also need to install the following GStreamer plugins: ‘good’, ‘ugly’, ‘bad’, ffmpeg (0.10), and libav (1.x). These additional plugins contain various codecs for audio and video decoding, as well as the necessary components for using the camera APIs. The package names for GStreamer vary between Linux distributions; try searching for gstreamer or libgstreamer in your distribution’s package repository to find suitable packages.
Speech Dependencies
Qt Speech depends on Speech Dispatcher (libspeechd) on the Linux platform. The following development packages should be installed:
- flite1-dev
- libspeechd-dev
- speech-dispatcher
Qt WebEngine Dependencies
Qt WebEngine has additional build requirements which are listed in the Qt WebEngine Platform Notes.
QDoc Dependencies
Since version 5.11, QDoc uses Clang to parse C++ code. If you wish to build QDoc manually, refer to Installing Clang for QDoc for specific build requirements.
В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Источник
Qt Documentation
Contents
This documentation discusses specific deployment issues for Qt for Linux/X11. We will demonstrate the procedures in terms of deploying the Plug & Paint application that is provided in Qt’s examples directory.
Due to the proliferation of Unix systems (such as commercial Unixes, Linux distributions, and so on), deployment on Unix is a complex topic. Before we start, be aware that programs compiled for one Unix flavor will probably not run on a different Unix system. For example, unless you use a cross-compiler, you cannot compile your application on Irix and distribute it on AIX.
Static Linking
Static linking is often the safest and easiest way to distribute an application on Unix since it relieves you from the task of distributing the Qt libraries and ensuring that they are located in the default search path for libraries on the target system.
Building Qt Statically
To use this approach, you must start by installing a static version of the Qt library:
We specify the prefix so that we do not overwrite the existing Qt installation. The example above only builds the Qt libraries, i.e. the examples and Qt Designer will not be built. When make is done, you will find the Qt libraries in the /path/to/Qt/lib directory.
When linking your application against static Qt libraries, note that you might need to add more libraries to the LIBS line in your project file. For more information, see the Application Dependencies section.
Linking the Application to the Static Version of Qt
Once Qt is built statically, the next step is to regenerate the makefile and rebuild the application. First, we must go into the directory that contains the application:
Now run qmake to create a new makefile for the application, and do a clean build to create the statically linked executable:
You probably want to link against the release libraries, and you can specify this when invoking qmake . Note that we must set the path to the static Qt that we just built.
To check that the application really links statically with Qt, run the ldd tool (available on most Unices):
Verify that the Qt libraries are not mentioned in the output.
Now, provided that everything compiled and linked without any errors, we should have a plugandpaint file that is ready for deployment. One easy way to check that the application really can be run stand-alone is to copy it to a machine that doesn’t have Qt or any Qt applications installed, and run it on that machine.
Remember that if your application depends on compiler specific libraries, these must still be redistributed along with your application. For more information, see the Application Dependencies section.
The Plug & Paint example consists of several components: The core application (Plug & Paint), and the Basic Tools and Extra Filters plugins. Since we cannot deploy plugins using the static linking approach, the executable we have prepared so far is incomplete. The application will run, but the functionality will be disabled due to the missing plugins. To deploy plugin-based applications we should use the shared library approach.
Shared Libraries
We have two challenges when deploying the Plug & Paint application using the shared libraries approach: The Qt runtime has to be correctly redistributed along with the application executable, and the plugins have to be installed in the correct location on the target system so that the application can find them.
Building Qt as a Shared Library
We assume that you already have installed Qt as a shared library, which is the default when installing Qt, in the /path/to/Qt directory.
Linking the Application to Qt as a Shared Library
After ensuring that Qt is built as a shared library, we can build the Plug & Paint application. First, we must go into the directory that contains the application:
Now run qmake to create a new makefile for the application, and do a clean build to create the dynamically linked executable:
This builds the core application, the following will build the plugins:
If everything compiled and linked without any errors, we will get a plugandpaint executable and the libpnp_basictools.so and libpnp_extrafilters.so plugin files.
Creating the Application Package
There is no standard package management on Unix, so the method we present below is a generic solution. See the documentation for your target system for information on how to create a package.
To deploy the application, we must make sure that we copy the relevant Qt libraries (corresponding to the Qt modules used in the application), the platform plugin, and the executable to the same directory tree. Remember that if your application depends on compiler specific libraries, these must also be redistributed along with your application. For more information, see the Application Dependencies section.
We’ll cover the plugins shortly, but the main issue with shared libraries is that you must ensure that the dynamic linker will find the Qt libraries. Unless told otherwise, the dynamic linker doesn’t search the directory where your application resides. There are many ways to solve this:
- You can install the Qt libraries in one of the system library paths (e.g. /usr/lib on most systems).
- You can pass a predetermined path to the -rpath command-line option when linking the application. This will tell the dynamic linker to look in this directory when starting your application.
- You can write a startup script for your application, where you modify the dynamic linker configuration (e.g., adding your application’s directory to the LD_LIBRARY_PATH environment variable.
Note: If your application will be running with «Set user ID on execution,» and if it will be owned by root, then LD_LIBRARY_PATH will be ignored on some platforms. In this case, use of the LD_LIBRARY_PATH approach is not an option).
The disadvantage of the first approach is that the user must have super user privileges. The disadvantage of the second approach is that the user may not have privileges to install into the predetermined path. In either case, the users don’t have the option of installing to their home directory. We recommend using the third approach since it is the most flexible. For example, a plugandpaint.sh script will look like this:
By running this script instead of the executable, you are sure that the Qt libraries will be found by the dynamic linker. Note that you only have to rename the script to use it with other applications.
When looking for plugins, the application searches in a plugins subdirectory inside the directory of the application executable. Either you have to manually copy the plugins into the plugins directory, or you can set the DESTDIR in the plugins’ project files:
An archive distributing all the Qt libraries, and all the plugins, required to run the Plug & Paint application, would have to include the following files:
Component | File Name | |
---|---|---|
The executable | plugandpaint | |
The script to run the executable | plugandpaint.sh | |
The Basic Tools plugin | plugins\libpnp_basictools.so | |
The ExtraFilters plugin | plugins\libpnp_extrafilters.so | |
The Qt xcb platform plugin | platforms\libqxcb.so | |
The Qt Core module | libQt5Core.so.5 | |
The Qt GUI module | libQt5Gui.so.5 | |
The Qt Widgets module | libQt5Widgets.so.5 |
On most systems, the extension for shared libraries is .so . A notable exception is HP-UX, which uses .sl .
Remember that if your application depends on compiler specific libraries, these must still be redistributed along with your application. For more information, see the Application Dependencies section.
To verify that the application now can be successfully deployed, you can extract this archive on a machine without Qt and without any compiler installed, and try to run it, i.e. run the plugandpaint.sh script.
An alternative to putting the plugins in the plugins subdirectory is to add a custom search path when you start your application using QApplication::addLibraryPath() or QApplication::setLibraryPaths().
Application Dependencies
Additional Libraries
To find out which libraries your application depends on, run the ldd tool (available on most Unices):
This will list all the shared library dependencies for your application. Depending on configuration, these libraries must be redistributed along with your application. In particular, the standard C++ library must be redistributed if you’re compiling your application with a compiler that is binary incompatible with the system compiler. When possible, the safest solution is to link against these libraries statically.
You will probably want to link dynamically with the regular X11 libraries, since some implementations will try to open other shared libraries with dlopen() , and if this fails, the X11 library might cause your application to crash.
It’s also worth mentioning that Qt will look for certain X11 extensions, such as Xinerama and Xrandr, and possibly pull them in, including all the libraries that they link against. If you can’t guarantee the presence of a certain extension, the safest approach is to disable it when configuring Qt (e.g. ./configure -no-xrandr ).
FontConfig and FreeType are other examples of libraries that aren’t always available or that aren’t always binary compatible. As strange as it may sound, some software vendors have had success by compiling their software on very old machines and have been very careful not to upgrade any of the software running on them.
When linking your application against the static Qt libraries, you must explicitly link with the dependent libraries mentioned above. Do this by adding them to the LIBS variable in your project file.
From Qt version 5.2 onwards, the officially supported version for OpenSSL is 1.0.0 or later. Versions >= 0.9.7 and libqxcb.so . This file must be located within a specific subdirectory (by default, platforms ) under your distribution directory. Alternatively, it is possible to adjust the search path Qt uses to find its plugins, as described below.
Your application may also depend on one or more Qt plugins, such as the JPEG image format plugin or a SQL driver plugin. Be sure to distribute any Qt plugins that you need with your application. Similar to the platform plugin, each type of plugin must be located within a specific subdirectory (such as imageformats or sqldrivers ) within your distribution directory.
The search path for Qt plugins (as well as a few other paths) is hard-coded into the QtCore library. By default, the first plugin search path will be hard-coded as /path/to/Qt/plugins . As mentioned above, using predetermined paths has certain disadvantages, so you need to examine various alternatives to make sure that the Qt plugins are found:
- Using qt.conf . This is the recommended approach since it provides the most flexibility.
- Using QApplication::addLibraryPath() or QApplication::setLibraryPaths().
- Using a third party installation utility or the target system’s package manager to change the hard-coded paths in the QtCore library.
The How to Create Qt Plugins document outlines the issues you need to pay attention to when building and deploying plugins for Qt applications.
В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Источник