Introduction to Qt4
The Qt4 package contains several
C++ libraries with both GUI and
non-GUI components. One of the major users of Qt4 is KDE4.
Package Information
Qt Dependencies
Required
X Window
System
Recommended
libjpeg-8c, libmng-1.0.10,
LibTIFF-4.0.0, and libpng-1.5.7
Optional
D-BUS-1.4.16, GStreamer Base
Plug-ins-0.10.25, PulseAudio-0.9.23, GLib-2.30.1,
gtk+-2.24.8, OpenSSL-1.0.0e, Cups-1.5.0, MySQL-5.5.17, PostgreSQL-9.0.6, unixODBC-2.3.0, and SQLite-3.7.8
User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/qt4
Installation of Qt4
There are several ways to install a complicated package such as
Qt4. 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 Qt4,
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 this method 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.
Note
There is no conflict between the Qt3 and Qt4
applications and headers so both can be installed at the same
time. This may be necessary to build or run Qt3 applications like
KDE3 and Qt4 applications like Doxygen's doxywizard on the same system.
To set up both Qt3 and
Qt4 on the same system, choose
the primary version for the /opt/qt
symbolic link and add the explicit library directory of the other
version to /etc/ld.so.conf
.
On a system with both versions of Qt, there is a name conflict
with Qt applications such as qmake
,
assistant
, and designer
. In such a case, make sure the PATH
variable lists the proper /opt/qt<version>/bin
directory before the
other Qt bin directory.
Caution
If Qt4 is being reinstalled and
the /usr
directory is used as the
prefix, run the following commands from a console or non-Qt4
based window manager. It overwrites Qt4 libraries that should not be in use
during the install process.
Note
The build time and space required for the full Qt4 is quite long. The instructions below do
not build the tutorials and examples. Removing the -nomake
lines will create a
complete build.
The method recommended by the Qt4
developers does not use the /usr directory prefix. It has the
advantage of keeping 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.
The Qt4 developers use a default
location of /usr/local/qt/
, however
the procedure below puts the files in /opt/qt-4.8.0/
and then creates a symbolic link
to /opt/qt/
.
Install Qt4 by running the
following commands:
./configure -prefix /opt/qt-4.8.0 \
-release \
-nomake examples \
-nomake demos \
-system-sqlite \
-no-nis \
&&
make
Phonon
If KDE4 is intended to be
installed, add -no-phonon
to the
./configure command
above. While installing KDE4, a
separate version of the Phonon
libraries will be installed which better matches the needs of the
KDE4 desktop.
This package does not come with a test suite.
Now, as the root
user:
make install
If you installed Qt4 in the /opt
directory, again as the root
user
issue:
ln -v -sfn qt-4.8.0 /opt/qt
Command Explanations
-nomake examples, -nomake
demos
: These switches disable building programs that
are only of interest to a Qt4
developer.
There are several optional directories that can be specified in the
./configure line.
These include -bindir
, -libdir
, -docdir
, and
-headerdir
. For a complete list, run
./configure -help.
-plugin-sql-<driver>
or
-qt-sql-<driver>
: These
switches build SQL support into the Qt4 libraries.
Note
To check if mysql is
autodetected properly, examine the output of ./configure -qt-sql-mysql
-help. Other database support will require
similar configure
parameters.
Configuring Qt4
Configuration
Information
If you installed Qt4 in a
location other than /usr, you also 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 qt addition to /etc/ld.so.conf
/opt/qt/lib
# End qt addition
EOF
ldconfig
Update the PKG_CONFIG_PATH
environment
variable in your ~/.bash_profile
or
/etc/profile
with the following:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/qt/lib/pkgconfig
If you want the Qt4 executables
in your shell search path, update the PATH
environment variable in your ~/.bash_profile
or /etc/profile
to include /opt/qt/bin
.