qt-alternate-5.15.12

Introduction to qt5 (alternate)

Qt5 is a cross-platform application framework that is widely used for developing application software with a graphical user interface (GUI) (in which cases qt5 is classified as a widget toolkit), and also used for developing non-GUI programs such as command-line tools and consoles for servers. Two of the major users of qt are KDE Frameworks 5 (KF5) and LXQt.

[Important]

Important

The full qt5 package consists of 43 separate components. These instructions use a small subset of the full qt5 installation instructions above. They cover most, but not all, of the components needed to build packages in BLFS. This page, and the next, are provided to reduce the amount of time, space, and dependencies needed to build these packages. They are not recommended if you will build the KDE Frameworks-5.115.0 based Plasma-5.27.10 desktop environment.

This package is known to build and work properly using an LFS 12.1 platform.

Package Information

Additional Downloads

qt5 Dependencies

Required

Xorg Libraries

Recommended

Optional

GTK+-3.24.41, libinput-1.25.0 MariaDB-10.11.7 or MySQL, MIT Kerberos V5-1.21.2, mtdev-1.1.6 PostgreSQL-16.2, and unixODBC-2.3.12

Setting the installation prefix

Installing in /opt/qt5

The BLFS editors recommend installing qt5 in a directory other than /usr, i.e. /opt/qt5. To do this, set the following environment variable:

export QT5PREFIX=/opt/qt5
[Tip]

Tip

Sometimes, the installation paths are hardcoded into installed files. This is the reason why /opt/qt5 is used as installation prefix instead of /opt/qt-5.15.12. To create a versioned qt5 directory after the installation is complete, you may rename the directory and create a symlink:

mkdir -pv /opt/qt-5.15.12
ln -sfnv qt-5.15.12 /opt/qt5

Later on, you may want to install other versions of qt5. To do that, just remove the symlink and use /opt/qt5 as the prefix again. Which version of qt5 you use depends only on where the symlink points.

Installation of qt5

[Warning]

Warning

If qt5 is being reinstalled into the same directory as an existing instance, run the commands done by root, such as make install, from a console or non-qt5 based window manager. It overwrites qt5 libraries that should not be in use during the install process.

[Caution]

Caution

If you did not install some of the recommended dependencies, examine ./configure --help output to check how to disable them or use internal versions bundled in the source tarball.

[Note]

Note

The BLFS editors do not recommend installing qt5 into the /usr hierarchy because it becomes difficult to find components and to update to a new version. If you do want to install qt5 in /usr, the directories need to be specified explicitly. In this case, set QT5PREFIX=/usr and add the following to the configure arguments below:

            -archdatadir    /usr/lib/qt5                \
            -bindir         /usr/bin                    \
            -plugindir      /usr/lib/qt5/plugins        \
            -importdir      /usr/lib/qt5/imports        \
            -headerdir      /usr/include/qt5            \
            -datadir        /usr/share/qt5              \
            -docdir         /usr/share/doc/qt5          \
            -translationdir /usr/share/qt5/translations \
            -examplesdir    /usr/share/doc/qt5/examples

Now apply a patch to pull in the fixes curated by kde for those modules which are required by packages mentioned in this book:

patch -Np1 -i ../qt-everywhere-opensource-src-5.15.12-kf5-1.patch

The patch is supposed to be used in a git repository. Otherwise some files that should be modified by configure after applying the patch are not touched. Fortunately, it is enough to create a .git directory in the qmake directory where the configure script is run:

mkdir -pv qtbase/.git

Fix a security vulnerability in qtbase:

patch -Np1 -i ../qt-everywhere-opensource-src-5.15.12-security_fix-1.patch

At this point we want to set up skipping most components. Do that with:

ls -Fd qt* | grep / | sed 's/^/-skip /;s@/@@' > tempconf &&
sed -i -r '/base|tools|x11extras|svg|declarative|wayland/d' tempconf

Now, install qt5 by running the following commands:

./configure -prefix $QT5PREFIX   \
            -sysconfdir /etc/xdg \
            -confirm-license     \
            -opensource          \
            -dbus-linked         \
            -openssl-linked      \
            -system-harfbuzz     \
            -system-sqlite       \
            -nomake examples     \
            -no-rpath            \
            -syslog              \
            $(cat tempconf)      \
            &&
make

This package does not come with a test suite.

Now, as the root user:

make install

Remove references to the build directory from installed library dependency (prl) files by running the following command as the root user:

find $QT5PREFIX/ -name \*.prl \
   -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

Install images and create the menu entries for installed applications. The QT5BINDIR variable is used here to point to the directory for the executable programs. If you have changed the bindir above, QT5BINDIR will need to be adjusted below. Be sure that the QT5BINDIR variable is defined in root's environment and as the root user:

QT5BINDIR=$QT5PREFIX/bin

install -v -dm755 /usr/share/pixmaps/                  &&

install -v -Dm644 qttools/src/assistant/assistant/images/assistant-128.png \
                  /usr/share/pixmaps/assistant-qt5.png &&

install -v -Dm644 qttools/src/designer/src/designer/images/designer.png \
                  /usr/share/pixmaps/designer-qt5.png  &&

install -v -Dm644 qttools/src/linguist/linguist/images/icons/linguist-128-32.png \
                  /usr/share/pixmaps/linguist-qt5.png  &&

install -v -Dm644 qttools/src/qdbus/qdbusviewer/images/qdbusviewer-128.png \
                  /usr/share/pixmaps/qdbusviewer-qt5.png &&

install -dm755 /usr/share/applications &&

cat > /usr/share/applications/assistant-qt5.desktop << EOF
[Desktop Entry]
Name=Qt5 Assistant
Comment=Shows Qt5 documentation and examples
Exec=$QT5BINDIR/assistant
Icon=assistant-qt5.png
Terminal=false
Encoding=UTF-8
Type=Application
Categories=Qt;Development;Documentation;
EOF

cat > /usr/share/applications/designer-qt5.desktop << EOF
[Desktop Entry]
Name=Qt5 Designer
GenericName=Interface Designer
Comment=Design GUIs for Qt5 applications
Exec=$QT5BINDIR/designer
Icon=designer-qt5.png
MimeType=application/x-designer;
Terminal=false
Encoding=UTF-8
Type=Application
Categories=Qt;Development;
EOF

cat > /usr/share/applications/linguist-qt5.desktop << EOF
[Desktop Entry]
Name=Qt5 Linguist
Comment=Add translations to Qt5 applications
Exec=$QT5BINDIR/linguist
Icon=linguist-qt5.png
MimeType=text/vnd.trolltech.linguist;application/x-linguist;
Terminal=false
Encoding=UTF-8
Type=Application
Categories=Qt;Development;
EOF

cat > /usr/share/applications/qdbusviewer-qt5.desktop << EOF
[Desktop Entry]
Name=Qt5 QDbusViewer
GenericName=D-Bus Debugger
Comment=Debug D-Bus applications
Exec=$QT5BINDIR/qdbusviewer
Icon=qdbusviewer-qt5.png
Terminal=false
Encoding=UTF-8
Type=Application
Categories=Qt;Development;Debugger;
EOF

Some packages such as VLC-3.0.20 look for certain executables with a -qt5 suffix. Run the following command as the root user to create the necessary symlinks:

for file in moc uic rcc qmake lconvert lrelease lupdate; do
  ln -sfvn $QT5BINDIR/$file /usr/bin/$file-qt5
done

Command Explanations

-confirm-license: Accept license without prompting user during configuration.

-opensource: Install the opensource version of qt.

-nomake examples: This switch disables building of the example programs included in the source tarball. Remove it if you want to build them.

-system-sqlite: This switch enables use of the system version of SQLite.

-system-harfbuzz: This switch enables use of the system version of Harfbuzz.

-dbus-linked -openssl-linked: These switches enable explicit linking of the D-Bus and OpenSSL libraries into qt5 libraries instead of dlopen()-ing them.

-syslog: This switch allows to send qt messages to the syslog logging system.

$(cat tempconf): This command provides a list of components that should not be built. These entries are in the form of "-skip <component>".

Configuring qt5

Configuration Information

If Sudo-1.9.15p5 is installed, QT5DIR should be available to the super user as well. Execute the following commands as the root user:

cat > /etc/sudoers.d/qt << "EOF"
Defaults env_keep += QT5DIR
EOF

If you installed qt5 in /usr

If you installed qt5 in /usr, create an environment variable needed by certain packages. As the root user:

cat > /etc/profile.d/qt5.sh << "EOF"
# Begin /etc/profile.d/qt5.sh

QT5DIR=/usr
export QT5DIR

# End /etc/profile.d/qt5.sh
EOF

If you did not install qt5 in /usr

If you installed qt5 in a location other than /usr, you need to update the following configuration files so that qt5 is correctly found by other packages and system processes.

As the root user, update the /etc/ld.so.conf file and the dynamic linker's run-time cache file:

cat >> /etc/ld.so.conf << EOF
# Begin Qt addition

/opt/qt5/lib

# End Qt addition
EOF

ldconfig

As the root user, create the /etc/profile.d/qt5.sh file:

cat > /etc/profile.d/qt5.sh << "EOF"
# Begin /etc/profile.d/qt5.sh

QT5DIR=/opt/qt5

pathappend $QT5DIR/bin           PATH
pathappend $QT5DIR/lib/pkgconfig PKG_CONFIG_PATH

export QT5DIR

# End /etc/profile.d/qt5.sh
EOF

Contents

Installed Programs: assistant, designer, fixqt4headers.pl, lconvert, linguist, lprodump, lrelease, lrelease-pro, lupdate, lupdate-pro, moc, pixeltool, qcollectiongenerator, qdbus, qdbuscpp2xml, qdbusviewer, qdbusxml2cpp, qdistancefieldgenerator, qdoc, qhelpgenerator, qlalr, qmake, qml, qmlcachegen, qmleasing, qmlformat, qmlimportscanner, qmllint, qmlmin, qmlplugindump, qmlpreview, qmlprofiler, qmlscene, qmltestrunner, qmltime, qmltyperegistrar, qtattributionscanner, qtdiag, qtpaths, qtplugininfo, qtwaylandscanner, qvkgen, rcc, syncqt.pl, tracegen, and uic
Installed Libraries: libQt5AccessibilitySupport.a, libQt5Bootstrap.a, libQt5Concurrent.so, libQt5Core.so, libQt5DBus.so, libQt5Designer.so, libQt5DesignerComponents.so, libQt5DeviceDiscoverySupport.a, libQt5EdidSupport.a, libQt5EglFSDeviceIntegration.so, libQt5EglFsKmsSupport.so, libQt5EglSupport.a, libQt5EventDispatcherSupport.a, libQt5FbSupport.a, libQt5FontDatabaseSupport.a, libQt5GlxSupport.a, libQt5Gui.so, libQt5Help.so, libQt5InputSupport.a, libQt5KmsSupport.a, libQt5LinuxAccessibilitySupport.a, libQt5Network.so, libQt5OpenGL.so, libQt5OpenGLExtensions.a, libQt5PacketProtocol.a, libQt5PlatformCompositorSupport.a, libQt5PrintSupport.so, libQt5Qml.so, libQt5QmlDebug.a, libQt5QmlDevTools.a, libQt5QmlModels.so, libQt5QmlWorkerScript.so, libQt5Quick.so, libQt5QuickParticles.so, libQt5QuickShapes.so, libQt5QuickTest.so, libQt5QuickWidgets.so, libQt5ServiceSupport.a, libQt5Sql.so, libQt5Svg.so, libQt5Test.so, libQt5ThemeSupport.a, libQt5UiTools.a, libQt5WaylandClient.so, libQt5WaylandCompositor.so, libQt5Widgets.so, libQt5X11Extras.so, libQt5XcbQpa.so, libQt5XkbCommonSupport.a, libQt5Xml.so, and several plugins under /opt/qt5/{plugins,qml}
Installed Directories: /usr/include/qt5, /usr/lib/qt5, /usr/share/doc/qt5, and /usr/share/qt5 OR /opt/qt5 and /opt/qt-5.15.12

Short Descriptions

See Qt5 Short Descriptions