Qt-4.8.6

Introduction to Qt4

Qt4 is a cross-platform application framework that is widely used for developing application software with a graphical user interface (GUI) (in which cases Qt4 is classifiedas 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 Qt4 is KDE.

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

Package Information

Qt4 Dependencies

Required

Xorg Libraries

Recommended

Optional

Cups-1.7.5, GTK+-2.24.24 (GTK+ 2 theme support), gst-plugins-base-0.10.36 (For QtWebKit HTML5 Video), MariaDB-10.0.13 or MySQL, 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/qt4

Setting the installation prefix

Installing in /usr

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

export QT4PREFIX=/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 Qt4 instance cannot be upgraded while it is in use. It also does not allow reverting to an existing, known working instance of Qt4.

Installing in /opt/qt4

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

export QT4PREFIX=/opt/qt4

The advantage of installing Qt4 in a custom directory such as /opt/qt4 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.

[Tip]

Tip

Sometimes, the installation paths are hardcoded into installed files. This is the reason why /opt/qt4 is used as installation prefix instead of /opt/qt-4.8.6. After installing Qt4, you may rename the directory and create a symlink:

mv /opt/qt{4,-4.8.6}
ln -sfv qt-4.8.6 /opt/qt4

Later on, you may want to install other versions of Qt4. To do that, just remove the symlink and use /opt/qt4 as the prefix again. Which version of Qt4 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 Qt5 ones. To accomplish that, set the following environment variable:

export QT4BINDIR=$QT4PREFIX/lib/qt4/bin

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

export QT4BINDIR=$QT4PREFIX/bin

Installation of Qt4

[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 Qt4 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-Qt4 based window manager. It overwrites Qt4 libraries that should not be in use during the install process.

[Note]

Note

The build time and space required for the full Qt is quite long. The instructions below do not build the tutorials and examples. Removing the -nomake lines will create a complete build.

Fix DoS vulnerability in the GIF image handler:

sed -i -e '631a if (image->isNull()) { state = Error; return -1; }' \
    src/gui/image/qgifhandler.cpp

Install Qt4 by running the following commands:

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

sed -i '/CONFIG -/ a\isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../..' \
     src/3rdparty/webkit/Source/WebKit2/DerivedSources.pro &&

./configure -prefix         $QT4PREFIX                        \
            -sysconfdir     /etc/xdg                          \
            -bindir         $QT4BINDIR                        \
            -plugindir      $QT4PREFIX/lib/qt4/plugins        \
            -importdir      $QT4PREFIX/lib/qt4/imports        \
            -headerdir      $QT4PREFIX/include/qt4            \
            -datadir        $QT4PREFIX/share/qt4              \
            -docdir         $QT4PREFIX/share/doc/qt4          \
            -translationdir $QT4PREFIX/share/qt4/translations \
            -demosdir       $QT4PREFIX/share/doc/qt4/demos    \
            -examplesdir    $QT4PREFIX/share/doc/qt4/examples \
            -confirm-license   \
            -opensource        \
            -release           \
            -dbus-linked       \
            -openssl-linked    \
            -system-sqlite     \
            -no-phonon         \
            -no-phonon-backend \
            -no-openvg         \
            -nomake demos      \
            -nomake examples   \
            -optimized-qmake   &&

make

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" {} \;
[Warning]

Warning

Make sure that QT4PREFIX and QT4BINDIR environment variables are set for the root user too.

Now, as the root user:

make install &&
rm -rf $QT4PREFIX/tests

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

for file in 3Support CLucene Core DBus Declarative DesignerComponents \
            Designer Gui Help Multimedia Network OpenGL Script \
            ScriptTools Sql Svg Test UiTools WebKit XmlPatterns Xml phonon; do

     [ -e $QT4PREFIX/lib/libQt${file}.prl ] &&
     sed -r '/^QMAKE_PRL_BUILD_DIR/d;s/(QMAKE_PRL_LIBS =).*/\1/' \
         -i $QT4PREFIX/lib/libQt${file}.prl
done
unset file

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

install -v -Dm644 src/gui/dialogs/images/qtlogo-64.png \
                  /usr/share/pixmaps/qt4logo.png &&

install -v -Dm644 tools/assistant/tools/assistant/images/assistant-128.png \
                  /usr/share/pixmaps/assistant-qt4.png &&

install -v -Dm644 tools/designer/src/designer/images/designer.png \
                  /usr/share/pixmaps/designer-qt4.png &&

install -v -Dm644 tools/linguist/linguist/images/icons/linguist-128-32.png \
                  /usr/share/pixmaps/linguist-qt4.png &&

install -v -Dm644 tools/qdbus/qdbusviewer/images/qdbusviewer-128.png \
                  /usr/share/pixmaps/qdbusviewer-qt4.png &&

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

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

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

cat > /usr/share/applications/linguist-qt4.desktop << EOF
[Desktop Entry]
Name=Qt4 Linguist 
Comment=Add translations to Qt4 applications
Exec=$QT4BINDIR/linguist
Icon=linguist-qt4.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-qt4.desktop << EOF
[Desktop Entry]
Name=Qt4 QDbusViewer 
GenericName=D-Bus Debugger
Comment=Debug D-Bus applications
Exec=$QT4BINDIR/qdbusviewer
Icon=qdbusviewer-qt4.png
Terminal=false
Encoding=UTF-8
Type=Application
Categories=Qt;Development;Debugger;
EOF

cat > /usr/share/applications/qtconfig-qt4.desktop << EOF
[Desktop Entry]
Name=Qt4 Config 
Comment=Configure Qt4 behavior, styles, fonts
Exec=$QT4BINDIR/qtconfig
Icon=qt4logo.png
Terminal=false
Encoding=UTF-8
Type=Application
Categories=Qt;Settings;
EOF

Some packages look for Qt4 executables with -qt4 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 qdoc3 qhelpconverter         \
            qhelpgenerator qmake qmlplugindump qmlviewer qt3to4   \
            qtconfig qttracereplay rcc uic uic3 xmlpatterns       \
            xmlpatternsvalidator
do
  ln -sfrv $QT4BINDIR/$file /usr/bin/$file-qt4
done
unset file

Command Explanations

sed -i ...: First command fixes detection of libmng 2.0 and second one prevents configure script from writing to the root directory if building as privileged user.

-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 -nomake demos: These switches disable building programs that are only of interest to a developer using Qt.

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

-no-phonon -no-phonon-backend: These switches disable building of the bundled Phonon library. Better version is provided by Phonon-4.8.0 package.

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

-no-openvg: This switch disables OpenVG support in Qt.

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

Configuring Qt4

Configuration Information

[Note]

Note

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

If you installed Qt4 in a location other than /usr, you need to update the following configuration files so that Qt4 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 Qt4 addition

$QT4PREFIX/lib

# End Qt4 addition
EOF

ldconfig

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

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

pathappend $QT4PREFIX/lib/pkgconfig PKG_CONFIG_PATH

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

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

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

pathappend $QT4BINDIR               PATH
pathappend $QT4PREFIX/lib/pkgconfig PKG_CONFIG_PATH

# End /etc/profile.d/qt4.sh
EOF
[Note]

Note

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

Contents

Installed Programs: assistant, designer, lconvert, linguist, lrelease, lupdate, moc, pixeltool, qcollectiongenerator, qdbuscpp2xml, qdbus, qdbusviewer, qdbusxml2cpp, qdoc3, qhelpconverter, qhelpgenerator, qmake, qmlplugindump, qmlviewer, qt3to4, qtconfig, qttracereplay, rcc, uic3, uic, xmlpatterns, and xmlpatternsvalidator
Installed Libraries: libQtUiTools.a, libQt3Support.so, libQtCLucene.so, libQtCore.so, libQtDBus.so, libQtDeclarative.so, libQtDesignerComponents.so, libQtDesigner.so, libQtGui.so, libQtHelp.so, libQtMultimedia.so, libQtNetwork.so, libQtOpenGL.so, libQtScript.so, libQtScriptTools.so, libQtSql.so, libQtSvg.so, libQtTest.so, libQtWebKit.so, libQtXmlPatterns.so, and libQtXml.so, and several plugins under /opt/qt4/imports and /opt/qt4/plugins
Installed Directories: $QT4PREFIX/include/qt4, $QT4PREFIX/lib/qt4, $QT4PREFIX/share/doc/qt4, and $QT4PREFIX/share/qt4

Short Descriptions

assistant

is a tool for presenting on-line documentation.

designer

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

provides support for translating applications into local languages.

lrelease

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

lupdate

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

generates Qt meta object support code.

pixeltool

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

qmake

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

qt3to4

qt3to4 is a tool to help update Qt3 code to Qt4.

qtconfig

is used to customize the appearance of Qt applications.

rcc

is a resource compiler used in conjunction with designer.

uic

is a Qt user interface compiler.

uic3

is a tool to generate Qt4 code out of user interface files generated by the Qt3 version of designer.

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