Linux HOWTOs

About | Home | Search


HOWTO: qt
Description: Multiplatform, C++ application framework
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# Qt/X11
# ======
# This is the open source version of Qt for X11.  If you are going to
# develop commercial/proprietary software, go to the Qt home page to read
# about the commercial version.

# Slackware 10.0's 'qt' package includes Qt 3.3.2, 10.1's includes 3.3.3,
# 10.2's includes 3.3.4, and 11.0's includes 3.3.6

# If you have trouble downloading with the URL below, try here:
# ftp://ftp.trolltech.com/qt/source/
# http://www.trolltech.com/developer/downloads/qt/x11

# I still haven't updated to Qt 4.x because the version of KDE that I use
# uses 3.x  4.x is not binary compatible, so it may be a hairy process.
# Though I'm not sure if they can co-exist or not.  Here is some info about
# it for when I decide to take the plunge:
# http://doc.trolltech.com/4.1/qt4-intro.html


# Qt 3.3.8
# ========
# If you're about to upgrade Qt, keep in mind that Qt-based things like KDE
# may not like the newer version of Qt.  Be prepared to rebuild/upgrade the
# Qt-based things too.  This version is said to maintain forward and
# backward compatibility with Qt 3.3.7, 3.3.6, 3.3.5, 3.3.4, 3.3.3, 3.3.2,
# 3.3.1, and Qt 3.3.0.  ...so you should be OK going from any 3.3.x version
# to this one, but you never know.

# Prerequisites:
# CUPS (optional)
# libmng (optional; leave off -system-libmng and -qt-imgfmt-mng if you don't
#   have it)
# libjpeg (optional; leave off -system-libjpeg and -qt-imgfmt-jpeg if you
#   don't have it)
# libpng (optional; leave off -system-libpng and -qt-imgfmt-png if you don't
#   have it)
# zlib (optional; leave off -system-zlib if you don't have it)
# NAS (optional)
# XFree86 or X.org
# MySQL (optional)

cd
test -f installed/qt-x11-free-3.3.8.tar.bz2 &&
 mv installed/qt-x11-free-3.3.8.tar.bz2 .
test ! -f qt-x11-free-3.3.8.tar.bz2 &&
 wget http://ftp.silug.org/mirrors/ftp.trolltech.com/qt/source/\
qt-x11-free-3.3.8.tar.bz2

# Verify tarball w/ md5sum:
echo "cf3c43a7dfde5bfb76f8001102fe6e85  qt-x11-free-3.3.8.tar.bz2" | \
 md5sum -c

# Now that you've downloaded a new version that you can replace it with,
# uninstall any previous versions of Qt that you have installed before
# building a new one.  If you don't, you'll end up with some files in
# /usr/lib/qt and some in /usr/lib/qt-3.3.8 or something like that (the
# build will use the old version).
su
test -x /sbin/removepkg && /sbin/removepkg qt
find /usr/lib -maxdepth 1 -type d -name "qt-?.*" -exec rm -r {} \;
test -d /usr/lib/qt && rm -r /usr/lib/qt
exit

# Unpack the source
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "qt-x11-free-*" -exec rm -r {} \;
tar xjvf ~/qt-x11-free-3.3.8.tar.bz2
cd qt-x11-free-3.3.8
test $UID = 0 && chown -R root:root .

# FYI, I use the same configure flags that Slackware does except that I shut
# off IPv6 support.

# If your MySQL is installed under the standard source-installed location
# of /usr/local/mysql, specify this on the configure line below so the Qt
# build can find the MySQL includes and libraries:
# -I/usr/local/mysql/include/mysql -L/usr/local/mysql/lib/mysql
#
# This should work if your MySQL is from a Slackware package:
# -I/usr/include/mysql -L/usr/lib/mysql
#
# If you don't have MySQL installed at all, leave off the -I and -L parts
# and leave off -plugin-sql-mysql

# If you end up needing to re-run configure a 2nd time for some reason,
# run 'make confclean' first.

# If you don't accept the license, don't run this:
echo "yes" | ./configure \
 -prefix /usr/lib/qt \
 -release \
 -system-zlib \
 -system-libpng \
 -qt-imgfmt-png \
 -system-libmng \
 -qt-imgfmt-mng \
 -system-libjpeg \
 -qt-imgfmt-jpeg \
 -qt-gif \
 -thread \
 -no-stl \
 -no-g++-exceptions \
 -xft \
 -plugin-sql-mysql \
 -plugin-style-cde \
 -plugin-style-compact \
 -qt-style-motif \
 -plugin-style-motifplus \
 -plugin-style-platinum \
 -plugin-style-sgi \
 -plugin-style-windows \
 -enable-opengl \
 -no-ipv6 \
 -I/usr/local/mysql/include/mysql \
 -L/usr/local/mysql/lib/mysql

# I run make like this because without it, it would fail in
# a few places saying that it can't find the Qt libraries:
make UIC="LD_LIBRARY_PATH=~/src/qt-x11-free-3.3.8/lib \
 ~/src/qt-x11-free-3.3.8/bin/uic \
 -L ~/src/qt-x11-free-3.3.8/plugins"

# Become root to install it
su

# Install the new version
make install

# Some files are created with r--r--r-- permissions.
# That's fine for the installed version, but we want to be able to delete
# the source directory as our non-root user later.
chmod -R u+w .

# If you run a Slackware new enough to have /etc/profile.d, run this to
# create a /etc/profile.d/qt.sh  If not, add everything but the commands
# that create output to /etc/profile.
cat << EOF > /etc/profile.d/qt.sh
#!/bin/sh
export QTDIR=/usr/lib/qt
if [ -n "\$CPLUS_INCLUDE_PATH" ]; then
  CPLUS_INCLUDE_PATH=\$QTDIR/include:\$CPLUS_INCLUDE_PATH
else
  CPLUS_INCLUDE_PATH=\$QTDIR/include
fi
export CPLUS_INCLUDE_PATH
export MANPATH="\$MANPATH:\$QTDIR/doc/man"
export PATH="\$PATH:\$QTDIR/bin"
if [ -d "\$QTDIR/lib/pkgconfig" -a ! -L "\$QTDIR/lib/pkgconfig" ]; then
  if [ -n "\$PKG_CONFIG_PATH" ]; then
    PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:\$QTDIR/lib/pkgconfig"
  else
    PKG_CONFIG_PATH="\$QTDIR/lib/pkgconfig"
  fi
  export PKG_CONFIG_PATH
fi
EOF
chmod +x /etc/profile.d/qt.sh

# FYI, Slackware's package includes several symlinks that we don't include
# because they're not required if you set QTDIR, update your PATH, etc.  If
# you have (for example) KDE's menu set to run /usr/bin/designer, make sure
# you either update the menu entry, or create a /usr/bin/designer symlink
# pointing to /usr/lib/qt/bin/designer.  The symlinks would be:
# /usr/bin/assistant (to /usr/lib/qt/bin/assistant)
# /usr/bin/designer
# /usr/bin/linguist
# /usr/bin/lrelease
# /usr/bin/lupdate
# /usr/bin/moc
# /usr/bin/qm2ts
# /usr/bin/qmake
# /usr/bin/qtconfig
# /usr/bin/uic
# /usr/doc/qt-3.3.8/examples
# /usr/doc/qt-3.3.8/html
# /usr/doc/qt-3.3.8/man
# /usr/doc/qt-3.3.8/tutorial
# /usr/lib/qt (to /usr/lib/qt-3.3.8)

# Become yourself again
exit

# Source the Qt environment variables into your shell
test -f /etc/profile.d/qt.sh && . /etc/profile.d/qt.sh

cd
mkdir -p -m 0700 installed
rm -f installed/qt-*.tar.*
mv qt-x11-free-3.3.8.tar.bz2 installed/

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>