Introduction to Qt5

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.

This package is known to build and work properly using an LFS-7.6 systemd platform.

Package Information

Qt5 Dependencies


alsa-lib-1.0.28, MesaLib-10.2.7, xcb-util-image-0.3.9, xcb-util-keysyms-0.3.9, xcb-util-renderutil-0.3.9, and xcb-util-wm-0.4.1



GeoClue-0.12.0, gst-plugins-base-1.4.1 (QtWebKit HTML5 Video Support), GTK+-2.24.24 (GTK+ Theme Support), IBus-1.5.8, MariaDB-10.0.13, PostgreSQL-9.3.5, PulseAudio-5.0, and unixODBC-2.3.2

Runtime Dependency

qtchooser-39 (required if installing both Qt4 and Qt5)

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/qt5

Setting the installation prefix

Installing in /usr

If you want to install Qt5 in /usr, set the following environment variable:

export QT5PREFIX=/usr

The advantage of installing in /usr is that no additional configuration is required. The package files are distributed within several subdirectories of the /usr hierarchy. This is the method that most distributions use. The disadvantage for BLFS users is that this Qt5 instance cannot be upgraded while it is in use. It also does not allow reverting to an existing, known working instance of Qt5.

Installing in /opt/qt5

If you want to install Qt5 in a directory other than /usr, ie /opt/qt5, set the following environment variable:

export QT5PREFIX=/opt/qt5

The advantage of installing Qt5 in a custom directory such as /opt/qt5 is that it keeps all the package files consolidated in a dedicated directory hierarchy. By using this method, an update can be made without overwriting a previous installation and users can easily revert to a previous version by changing one symbolic link or merely changing the PATH variable.



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.3.1. After installing Qt5, you may rename the directory and create a symlink:

mv /opt/qt{5,-5.3.1}
ln -sfv qt-5.3.1 /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 to.

Setting the install location for executables

Both Qt4 and Qt5 executables have the same names and will overwrite each other if they are installed in the same prefix. To overcome such problem, BLFS offers qtchooser-39, an utility used to switch between different Qt versions.

If qtchooser-39 is to be used or if installing both Qt4 and Qt5 in /usr, the executables need to be installed to a non-standard location in order to avoid the conflict with Qt4 ones. To accomplish that, set the following environment variable:

export QT5BINDIR=$QT5PREFIX/lib/qt5/bin

If you choose not to install qtchooser-39 or if you are not going to install Qt4, simply set the bindir to a bin subdir of the default prefix by setting the following environment variable:


Installation of Qt5



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.



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.

Install Qt5 by running the following commands:

./configure -prefix         $QT5PREFIX                        \
            -sysconfdir     /etc/xdg                          \
            -bindir         $QT5BINDIR                        \
            -headerdir      $QT5PREFIX/include/qt5            \
            -archdatadir    $QT5PREFIX/lib/qt5                \
            -datadir        $QT5PREFIX/share/qt5              \
            -docdir         $QT5PREFIX/share/doc/qt5          \
            -translationdir $QT5PREFIX/share/qt5/translations \
            -examplesdir    $QT5PREFIX/share/doc/qt5/examples \
            -confirm-license \
            -opensource      \
            -dbus-linked     \
            -openssl-linked  \
            -system-harfbuzz \
            -system-sqlite   \
            -nomake examples \
            -optimized-qmake &&

This package does not come with a test suite.

Remove references to the build directory from the .pc files by running the following command:

find . -name "*.pc" -exec perl -pi -e "s, -L$PWD/?\S+,,g" {} \;


Make sure that QT5PREFIX and QT5BINDIR environment variables are set for the root user too.

Now, as the root user:

make install

Remove references to the build directory from installed files by running the following commands as the root user:

sed -e "s:$PWD/qtbase:$QT5PREFIX/lib/qt5:g" \
    -i $QT5PREFIX/lib/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri &&

find $QT5PREFIX/lib/lib{Enginio,qgsttools_p,Qt5*}.prl -exec sed -i -r \
     '/^QMAKE_PRL_BUILD_DIR/d;s/(QMAKE_PRL_LIBS =).*/\1/' {} \;

Install images and create the menu entries for installed applications by running the following commands as the root user:

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 -v -dm755 /usr/share/applications &&

cat > /usr/share/applications/assistant-qt5.desktop << EOF
[Desktop Entry]
Name=Qt5 Assistant 
Comment=Shows Qt5 documentation and examples

cat > /usr/share/applications/designer-qt5.desktop << EOF
[Desktop Entry]
Name=Qt5 Designer
GenericName=Interface Designer
Comment=Design GUIs for Qt5 applications

cat > /usr/share/applications/linguist-qt5.desktop << EOF
[Desktop Entry]
Name=Qt5 Linguist
Comment=Add translations to Qt5 applications

cat > /usr/share/applications/qdbusviewer-qt5.desktop << EOF
[Desktop Entry]
Name=Qt5 QDbusViewer 
GenericName=D-Bus Debugger
Comment=Debug D-Bus applications

Some packages look for Qt5 executables with -qt5 suffix. Run the following command as the root user to create the necessary symlinks:

for file in assistant designer lconvert linguist lrelease lupdate   \
            moc pixeltool qcollectiongenerator qdbus qdbuscpp2xml   \
            qdbusviewer qdbusxml2cpp qdoc qhelpconverter            \
            qhelpgenerator qlalr qmake qml qml1plugindump qmlbundle \
            qmlimportscanner qmlmin qmlplugindump qmlprofiler       \
            qmlscene qmltestrunner qmlviewer qtdiag qtpaths         \
            rcc syncqt.pl uic xmlpatterns xmlpatternsvalidator
  ln -sfrv $QT5BINDIR/$file /usr/bin/$file-qt5
unset file

Command Explanations

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

-opensource: Install the opensource version of Qt.

-release: This switch disables building with debugging symbols.

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

-system-harfbuzz: This switch enables use of the system version of Harfbuzz which fixes some font rendering issues in Qt5 applications.

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

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

-optimized-qmake: This switch enables building of the optimized qmake program.

Configuring Qt5

Configuration Information



If you have installed Qt5 in /usr you can skip this section.

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 Qt5 addition


# End Qt5 addition


If you have installed qtchooser-39, create the /etc/profile.d/qt5.sh file by running the following command as the root user:

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

pathappend $QT5PREFIX/lib/pkgconfig PKG_CONFIG_PATH

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

If you have not installed qtchooser-39, create the /etc/profile.d/qt5.sh file by running the following command as the root user:

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

pathappend $QT5BINDIR               PATH
pathappend $QT5PREFIX/lib/pkgconfig PKG_CONFIG_PATH

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


If qtchooser-39 is not installed and you also have Qt4 installed, you will need to manually adjust the PATH variable depending on which Qt version is needed.


Installed Programs: assistant, designer, lconvert, linguist, lrelease, lupdate, moc, pixeltool, qcollectiongenerator, qdbuscpp2xml, qdbus, qdbusviewer, qdbusxml2cpp, qdoc, qhelpconverter, qhelpgenerator, qlalr, qmake, qml1plugindump, qmlbundle, qmlimportscanner, qmlmin, qmlplugindump, qmlprofiler, qml, qmlscene, qmltestrunner, qmlviewer, qtdiag, qtpaths, rcc, syncqt.pl, uic, xmlpatterns, and xmlpatternsvalidator
Installed Libraries: libEnginio.so, libqgsttools_p.so, libQt5Bluetooth.so, libQt5Bootstrap.a, libQt5CLucene.so, libQt5Concurrent.so, libQt5Core.so, libQt5DBus.so, libQt5Declarative.so, libQt5DesignerComponents.so, libQt5Designer.so, libQt5Gui.so, libQt5Help.so, libQt5MultimediaQuick_p.so, libQt5Multimedia.so, libQt5MultimediaWidgets.so, libQt5Network.so, libQt5Nfc.so, libQt5OpenGLExtensions.a, libQt5OpenGL.so, libQt5PlatformSupport.a, libQt5Positioning.so, libQt5PrintSupport.so, libQt5QmlDevTools.a, libQt5Qml.so, libQt5QuickParticles.so, libQt5QuickWidgets.so, libQt5Quick.so, libQt5QuickTest.so, libQt5Script.so, libQt5ScriptTools.so, libQt5Sensors.so, libQt5SerialPort.so, libQt5Sql.so, libQt5Svg.so, libQt5Test.so, libQt5UiTools.a, libQt5WebKit.so, libQt5WebKitWidgets.so, libQt5WebSockets.so, libQt5Widgets.so, libQt5X11Extras.so, libQt5XmlPatterns.so, libQt5Xml.so, and several plugins under /opt/qt5/{imports,plugins,qml}
Installed Directories: $QT5PREFIX/include/qt5, $QT5PREFIX/lib/qt5, $QT5PREFIX/share/doc/qt5, and $QT5PREFIX/share/qt5

Short Descriptions


is a tool for presenting on-line documentation.


is a full-fledged GUI builder. It includes powerful features such as preview mode, automatic widget layout, support for custom widgets, and an advanced property editor.


provides support for translating applications into local languages.


is a simple command line tool. It reads a Qt project file and produces message files used by the application.


reads a Qt project file, finds the translatable strings in the specified source, header and Qt Designer interface files, and produces or updates the translation files listed in the project file.


generates Qt meta object support code.


is a desktop magnifier and as you move your mouse around the screen it will show the magnified contents in its window.


uses information stored in project files to determine what should go in the makefiles it generates.


is a resource compiler used in conjunction with designer.


is a Qt user interface compiler.

Last updated on 2014-08-24 04:24:00 -0700