Qt-5.1.1

Introduction to Qt

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

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

Package Information

Qt Dependencies

Required

alsa-lib-1.0.27.2, MesaLib-9.2.0, xcb-util-image-0.3.9, xcb-util-keysyms-0.3.9, xcb-util-renderutil-0.3.8, and xcb-util-wm-0.3.9

Recommended

Optional

gst-plugins-base-1.0.10 (QtWebKit HTML5 Video Support), GTK+-2.24.20 (GTK+ Theme Support), libxkbcommon, MySQL-5.6.13, PostgreSQL-9.3.0, PulseAudio-4.0, unixODBC-2.3.1, and qtchooser-31 (runtime, if also installing Qt4 and installing in /usr)

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

Installation of Qt

There are several ways to install a complicated package such as Qt. The files are not completely position independent. Installation procedures execute the program pkg-config to determine the location of package executables, libraries, headers, and other files. For Qt, pkg-config will look for the appropriate lib/pkgconfig/Qt*.pc files which must be modified if relocating the package. These files are set up correctly by the build process.

The default installation places the files in /usr/local/qt/. Many commercial distributions place the files in the system's /usr hierarchy. The package can also be installed in an arbitrary directory.

The advantage of installing in /usr is that no updates to the /etc/ld.so.conf or /etc/man_db.conf files are required. The package files are distributed within several subdirectories of the /usr hierarchy. This is the method that most commercial distributions use.

The disadvantage of installing in /usr is that the executable filenames for Qt4 and Qt5 conflict if both packages are installed in the same directory. The instructions below give a workaround for this problem using the helper program qtchooser-31. This requires renaming the Qt executables with a version suffix.

The advantage of installing Qt4 in a custom directory such as /opt/qt-4.8.5 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. It also allows a developer to maintain multiple versions of Qt4 or Qt5 for testing.

[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.

[Warning]

Warning

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

Method 1: Installing in /usr

Install Qt5 by running the following commands:

[Note]

Note

If not also installing Qt4 into the /usr directory, change the entry for -bindir below to /usr/bin.

sed -i "s:Context\* context}:&\n%lex-param {YYLEX_PARAM}:" \
     qtwebkit/Source/ThirdParty/ANGLE/src/compiler/glslang.y &&

sed -i -e "/#if/d" -e "/#error/d" -e "/#endif/d" \
     qtimageformats/config.tests/libmng/libmng.cpp &&

./configure -prefix         /usr               \
            -sysconfdir     /etc/xdg           \
            -bindir         /usr/lib/qt5/bin   \
            -headerdir      /usr/include/qt5   \
            -archdatadir    /usr/lib/qt5       \
            -datadir        /usr/share/qt5     \
            -docdir         /usr/share/doc/qt5 \
            -translationdir /usr/share/qt5/translations \
            -examplesdir    /usr/share/doc/qt5/examples \
            -confirm-license   \
            -opensource        \
            -dbus-linked       \
            -openssl-linked    \
            -system-sqlite     \
            -no-nis            \
            -nomake examples   \
            -opengl es2        \
            -optimized-qmake   &&
make

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

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

This package does not come with a test suite.

Now, as the root user:

make install &&
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

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

sed -i -e "s:$PWD/qtbase:/usr/lib/qt5:g" \
    /usr/lib/qt5/mkspecs/modules/qt_lib_bootstrap.pri &&
find /usr/lib/*.prl -exec sed -i -e \
     '/^QMAKE_PRL_BUILD_DIR/d;s/\(QMAKE_PRL_LIBS =\).*/\1/' {} \;

If also installing Qt4 into /usr, Symlink the Qt5 executables into /usr/bin by running the following commands as the root user:

for file in /usr/lib/qt5/bin/*
do
  ln -sfv ../lib/qt5/bin/$(basename $file) /usr/bin/$(basename $file)-qt5
done

Method 2: Installing in /opt/qt-5.1.1

This section provides an alternate way to install Qt4 by installing almost all of the files in the /opt directory. This allows management of all Qt related files in one unit. For instance, a new version of Qt5 can be installed without over-writing the existing installation and entire Qt5 instances can be easily removed. However, it has the disadvantage of needing some extra configuration.

sed -i "s:Context\* context}:&\n%lex-param {YYLEX_PARAM}:" \
     qtwebkit/Source/ThirdParty/ANGLE/src/compiler/glslang.y &&

sed -i -e "/#if/d" -e "/#error/d" -e "/#endif/d" \
     qtimageformats/config.tests/libmng/libmng.cpp &&

QT5DIR=/opt/qt-5.1.1

./configure -prefix     $QT5DIR  \
            -sysconfdir /etc/xdg \
            -confirm-license     \
            -opensource          \
            -dbus-linked         \
            -openssl-linked      \
            -system-sqlite       \
            -plugin-sql-sqlite   \
            -no-nis              \
            -nomake examples     \
            -opengl es2          \
            -optimized-qmake     &&
make

Now, as the root user:

make install &&

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

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

find $QT5DIR -name qt_lib_bootstrap.pri \
   -exec sed -i -e "s:$PWD/qtbase:/$QT5DIR/lib/:g" {} \; &&

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

At this point is is useful to add some configuration items as the root user:

echo /opt/qt5 >> /etc/ld.so.conf &&
ldconfig                         &&

cat >> /etc/profile.d/qt5.sh << "EOF"
pathappend /opt/qt5/lib/pkgconfig PKG_CONFIG_PATH
EOF

Command Explanations

sed -i "..." ...: First command fixes building with Bison 3.0 and second command fixes detection of libmng 2.0.

-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-sqlite: This switch enables use of the system version of SQLite.

-no-nis: This switch disables support for Network Information Service (NIS) which has been removed from recent versions of Glibc.

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

-opengl es2: This switch enables OpenGL ES2 support in Qt.

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

Configuring Qt

Configuration Information

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

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

QTDIR=/usr

export QT5DIR

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

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.

[Note]

Note

If you also installed Qt4 and need to use the Qt5 version of an executable such as qmake for building a program, make sure that the Qt5 bin directory is listed prior to the Qt4 bin directory in the PATH variable.

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/qt.sh file:

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

QT5DIR=/opt/qt5

pathappend /opt/qt5/bin           PATH
pathappend /opt/qt5/lib/pkgconfig PKG_CONFIG_PATH

export QT5DIR

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

For all methods, create the menu entries for installed applications. As the root user:

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=assistant-qt5
Icon=assistant-qt5
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=designer-qt5
Icon=designer-qt5
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=linguist-qt5
Icon=linguist-qt5
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=qdbusviewer-qt5
Icon=qdbusviewer-qt5
Terminal=false
Encoding=UTF-8
Type=Application
Categories=Qt;Development;Debugger;
EOF

Contents

Installed Programs: assistant-qt5, designer-qt5, lconvert-qt5, linguist-qt5, lrelease-qt5, lupdate-qt5, moc-qt5, pixeltool-qt5, qcollectiongenerator-qt5, qdbuscpp2xml-qt5, qdbus-qt5, qdbusviewer-qt5, qdbusxml2cpp-qt5, qdoc-qt5, qhelpconverter-qt5, qhelpgenerator-qt5, qmake-qt5, qml1plugindump-qt5, qmlbundle-qt5, qmlmin-qt5, qmlplugindump-qt5, qmlprofiler-qt5, qmlscene-qt5, qmltestrunner-qt5, qmlviewer-qt5, rcc-qt5, syncqt.pl-qt5, uic-qt5, xmlpatterns-qt5, and xmlpatternsvalidator-qt5
Installed Libraries: libqgsttools_p.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, libQt5OpenGLExtensions.a, libQt5OpenGL.so, libQt5PlatformSupport.a, libQt5PrintSupport.so, libQt5QmlDevTools.a, libQt5Qml.so, libQt5QuickParticles.so, libQt5Quick.so, libQt5QuickTest.so, libQt5Script.so, libQt5ScriptTools.so, libQt5Sensors.so, libQt5SerialPort.so, libQt5Sql.so, libQt5Svg.so, libQt5Test.so, libQt5UiTools.a, libQt5V8.so, libQt5WebKit.so, libQt5WebKitWidgets.so, libQt5Widgets.so, libQt5X11Extras.so, libQt5XmlPatterns.so, and libQt5Xml.so
Installed Directories: /usr/include/qt5, /usr/lib/qt5, /usr/share/doc/qt5, and /usr/share/qt5

Short Descriptions

assistant-qt5

is a tool for presenting on-line documentation.

designer-qt5

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.

linguist-qt5

provides support for translating applications into local languages.

lrelease-qt5

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

lupdate-qt5

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.

moc-qt5

generates Qt meta object support code.

pixeltool-qt5

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

qmake-qt5

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

rcc-qt5

is a resource compiler used in conjunction with designer.

uic-qt5

is a Qt user interface compiler.

Last updated on 2013-09-09 10:09:36 -0700