Update to KDE hint

Adam Ottley aottley at shaw.ca
Tue Oct 30 17:34:06 PST 2001

I've made an update to the KDE hint to address a problem with missing 
headers.  Please replace the current one with this one.
-------------- next part --------------
TITLE:		KDE 2.2.1 optimized
AUTHOR:		Adam Ottley <aottley at shaw.ca>

	The point of this hint is to build not just a simple KDE2 install, but a 
highly optimized one.  KDE2 has a reputation for being somewhat of a slowpoke, 
but there are things you can do to alleviate that.  A couple of parts in this 
hint borrow from Bruce Dubbs's KDE hint, particularly the part about building 
a shared lcms library and the part about building libtiff.  This hint assumes 
you've followed the x11.txt hint and therefore have XFree86 and zlib installed.

	Oct 30/01: Add symlinks so libmng can find the lcms headers (/me smacks
his head and thanks Michael Aichler)


The packages you'll need:


  jpegsrc.v6b.tar.gz (http://www.ijg.org/)
  libpng-1.2.0.tar.gz (http://www.libpng.org/pub/png/libpng.html)
  tiff-v3.5.5.tar.gz (http://www.libtiff.org/tiff-v3.5.5.tar.gz) (We'll go 
without the beta version)
  libmng-1.0.3.tar.gz (http://www.libmng.com/)
  qt-x11-2.3.1.tar.gz (http://www.trolltech.com/)
  pcre-3.4.tar.gz (http://www.pcre.org/)
  audiofile-0.2.2.tar.gz (http://dreamscape.68k.org/~michael/audiofile/)
  libxml2-2.4.5.tar.gz (http://xmlsoft.org/)
  lcms-1.0.7.tar.gz (http://www.littlecms.com/)
  kdelibs-2.2.1.tar.bz2 (http://www.kde.org/)

Optional (but recommended) KDE packages:
  <whichever KDE localization (i18n) package you need>

KDE packages that developers may want:

----Optional packages----

  objprelink.c (http://www.research.att.com/~leonb/objprelink/howto.html)
Prelinks the C++ libs, resulting in faster startup.  You also should get the 
patch for QT from the site, and if you're compiling KOffice, get the KDE patch 
as well.

  libao-0.8.tar.gz, libogg-1.0rc2.tar.gz, libvorbis-1.0rc2.tar.gz
Needed for encoding audio CDs into Ogg Vorbis format using KDE's audiocd:/ 

  lame3.89beta.tar.gz (http://www.mp3dev.org/mp3/)
Needed for encoding audio CDs into MP3 using audiocd:/

  cdparanoia-III-alpha9.8.src.tgz (http://www.xiph.org/paranoia/)
Needed for CD ripping using audiocd:/

  openssl-0.9.6b.tar.gz (http://www.openssl.org/)
Needed for https:// support

  lesstif-0.93.12.tar.gz (http://www.lesstif.org/)
Needed to use Netscape browser plugins

Those are just the ones I installed; there are others you may find useful, 
but won't be covered in this hint (i.e. CUPS for integration into printing 
system, ghostscript for viewing PDF/PS docs in kghostview or printing to PDF 
in KDE apps, RPM for RPM support in kpackage, etc).



Choose your CFLAGS and CXXFLAGS wisely.  -march=i686 has been known to cause 
problems in some cases, and the truth is, -march=i686 rarely gives a 
noticeable speedup over using just -mcpu=i686.  I built everything in this 
hint using "-O3 -march=i386 -mcpu=i686" on a LFS 3.0 system, and have not had 
problems.  That said, set your CFLAGS and CXXFLAGS variables to your choice of 

  export CFLAGS='-O3 -march=i386 -mcpu=i686'
  export CXXFLAGS='-O3 -march=i386 -mcpu=i686'


jpeg v6b  (http://www.ijg.org/)

This library handles JPEG images.

Install jpeglib with these commands:

./configure --prefix=/usr --enable-shared --enable-static &&
make &&
make install


libpng 1.2.0  (http://www.libpng.org/pub/png/libpng.html)

WARNING: If you already have libpng-1.0.x installed and have apps linked to 
it, it is recommended that you NOT install libpng-1.2.0.  Conflicts may occur 
if you do.

libpng is used for portable network graphics images, which are losslessly 
compressed and used extensively in KDE.

Copy the appropriate makefile from the scripts directory to the root libpng 
directory.  makefile.linux is the obvious choice, but you can use 
makefile.gcmmx to get MMX optimizations if you like.

  cp scripts/makefile.linux Makefile

Now edit the Makefile and change








and add any optimization flags you want to the CFLAGS declaration.  After 
that, it's just

  make &&
  make install

to install libpng.


lcms 1.07  (http://www.littlecms.com/)

LCMS is a colour management system.

Edit the install.gcc file to add the optimizations you want to the gcc line.  
i.e: gcc -O3 -march=i386 -mcpu=i686 -c *.c
You will get an error at the end of the build, but that's just a test of the 
library failing because of a missing parameter. The test will not fail if you 
add -lm after /usr/lib/liblcms.a in the second-last line of install.gcc.

To build and install the static library, run


I had to build a shared library in order for QT to successfully build against
libmng, so do that using these commands:

  cd src &&
  gcc -o liblcms.so.1.0.7 -shared cmscnvrt.o cmserr.o cmsgamma.o cmsgmt.o \
cmsintrp.o cmsio1.o cmslut.o cmsmatsh.o cmsmtrx.o cmspack.o cmspcs.o \
cmswtpnt.o cmsxform.o &&
  cp liblcms.so.1.0.7 /usr/lib &&
  cd /usr/lib &&
  ln -s liblcms.so.1.0.7 liblcms.so.1 &&
  ln -s liblcms.so.1 libcms.so

Some programs (like libmng) look in different places for the lcms headers, so
we'll set up symlinks with these commands:

  mkdir /usr/include/lcms &&
  cd /usr/include/lcms &&
  ln -s ../lcms.h lcms.h &&
  ln -s ../icc34.h icc34.h


libmng 1.0.3  (http://www.libmng.com/)

Libmng is basically animated PNG.  With the patent controversy over GIF, 
there's been a call to replace GIF with PNG, but until MNG there was nothing 
to replace animated GIF.

Install libmng with these commands:

  ./configure --prefix=/usr --with-zlib --with-jpeg --with-lcms &&
  make &&
  make install


libtiff 3.5.5  (http://www.libtiff.org/tiff-v3.5.5.tar.gz)

libtiff handles TIFF format images.

Edit the config.site file and remove /local from the DIR_BIN, DIR_INC, 
DIR_LIB, and DIR_MAN declarations, and uncomment the lines.  The following 
section, courtesy of Bruce Dubbs's KDE LFS hint, fixes the problem where a 
shared library isn't built.


There are a few bugs in the Linux portions of the install scripts.
In 'configure', look around line 1158 for:

        if [ -r /lib/libc.so.6 || -r /lib/libc.so.5 ]; then

Change the || characters to -o and comment out the line starting with 
DSOSUF_VERSION and add a new line to change it as shown below:

        if [ -r /lib/libc.so.6 -o -r /lib/libc.so.5 ]; then

The installation code for Linux is not correct either.  In 
'libtiff/Makefile.in' look about line 327 for the following code:

installDSO: @DSO at dso
        if [ @DSOSUF_VERSION@ != @DSOSUF@ ]; then                       \
            ${INSTALL} -idb tiff.sw.tools -m 555 -F @DIR_LIB@           \
                -O libtiff. at DSOSUF_VERSION@;                            \
            ${INSTALL} -idb tiff.sw.tools -F @DIR_LIB@                  \
                -ln libtiff. at DSOSUF_VERSION@ -O libtiff. at DSOSUF@;       \
        else                                                            \
            ${INSTALL} -idb tiff.sw.tools -m 555 -F @DIR_LIB@           \
                -O libtiff. at DSOSUF@;                                    \

We need to change the '-ln' in the sixth line above to '-lns' in order
for the system to make a symbolic link. We also need to add two new
lines as shown below to install a libtiff.so symboloc link.

installDSO: @DSO at dso
        if [ @DSOSUF_VERSION@ != @DSOSUF@ ]; then                       \
            ${INSTALL} -idb tiff.sw.tools -m 555 -F @DIR_LIB@           \
                -O libtiff. at DSOSUF_VERSION@;                            \
            ${INSTALL} -idb tiff.sw.tools -F @DIR_LIB@                  \
                -lns libtiff. at DSOSUF_VERSION@ -O libtiff. at DSOSUF@;      \
            ${INSTALL} -idb tiff.sw.tools -F @DIR_LIB@                  \
                -lns libtiff. at DSOSUF@ -O libtiff.so;                    \
        else                                                            \
            ${INSTALL} -idb tiff.sw.tools -m 555 -F @DIR_LIB@           \
                -O libtiff. at DSOSUF@;                                    \


Configure tiff:

  ./configure --noninteractive

In the make line, we'll avoid inserting debug code by unsetting COPTS:

  make install

For me, the make install didn't install the shared library into /usr/lib, but 
that can be done manually.

  cp -a libtiff/libtiff.so* /usr/lib
  cd /usr/lib
  ln -s libtiff.so.3 libtiff.so


pcre 3.4  (http://www.pcre.org/)

PCRE stands for perl-compatible regular expressions, and is used by KDE for 
regular expressions in Javascript.

Install pcre with these commands:

  ./configure --prefix=/usr &&
  make &&
  make install


libxml2 2.4.5  (http://xmlsoft.org/)

Formerly a part of the kdesupport package, libxml2 is is used for KDE's 

Install libxml2 with these commands:

  ./configure --prefix=/usr --with-zlib=/usr &&
  make &&
  make install


audiofile 0.2.2  (http://dreamscape.68k.org/~michael/audiofile/)

Also a former part of kdesupport, you need audiofile for sound in KDE.

Install audiofile with these commands:

  ./configure --prefix=/usr &&
  make &&
  make install


objprelink  (http://www.research.att.com/~leonb/objprelink/howto.html)

This part is optional, but highly recommended.  You'll need the lastest 
version of binutils (2.11.2 at this point), and if any of glibc, gcc or 
binutils were compiled with optimizations there is a chance that everything 
you prelink will segfault when run.  Prelinking failed for me on my LFS 2.4.3 
system where those were built with optimizations; on a LFS 3.0 system where 
glibc, gcc and binutils were compiled with no optimizations and everything 
else was built -O3 -march=i386 -mcpu=i686, prelinking worked fine.  Proceed 
with caution.

That said, build and install objprelink with these commands:

  gcc -o objprelink -O2 objprelink.c -lbfd -liberty &&
  cp objprelink /usr/bin

We can dynamically link with libbfd because the reason for statically linking 
given on the objprelink page doesn't apply to LFS.


qt 2.3.1  (http://www.trolltech.com/)

The C++ GUI toolkit on which KDE is built may take an hour or two to compile.  
We'll save time by not compiling some of the things that aren't needed.

Personally, I unpack qt into /usr/lib/qt-2.3.1 and make a symlink /usr/lib/qt2 
that points to qt-2.3.1.  You may have to add /usr/lib/qt2/lib to 
/etc/ld.so.conf, which I do just in case.

If you're prelinking, then apply the patch:

  cd configs
  patch -Np1 -i ../qt-configs.patch
  cd ..

This will patch the file linux-g++-shared.  You can also edit the 
linux-g++-shared file and add your optimizations to the SYSCONF_CXXFLAGS and 

Now configure qt:

  export QTDIR=$PWD
  ./configure -shared -sm -thread -gif -system-libpng -system-libmng \
-system-zlib -system-jpeg -no-opengl -xft -no-g++-exceptions

Configure parameter explanations:

  -gif -system-libpng -system-libmng -system-zlib -system-jpeg:  
By default, GIF support is disabled and QT uses its own included zlib, libmng, 
libpng and jpeglib distributions.  We want it to use the libs we've already 
built, and we want GIF support, so we tell configure that.

OpenGL support isn't needed.

Build with font antialiasing support.

Building QT without exceptions cuts a few megabytes off of the library size 
and speeds it up noticeably.

Now compile QT by running:

  make symlinks sub-src sub-tools

And let it run for a while.  Telling it to make just those targets will keep 
it from compiling the tutorial and examples which aren't needed.  If you 
applied the objprelink patch and the build process unexpectedly stops with a 
segmentation fault when it runs "moc", that's an indication that prelinking 
will not work on your system.  I wish I knew what to do about it, but there 
is no known fix right now.

Once the make process is finished, that's it for building QT.

Since font anti-aliasing support has been compiled in, you'll need to add the 
path to your TrueType fonts to /etc/X11/XftConfig.  Just insert the line:

  dir "/usr/X11R6/lib/X11/fonts/TrueType"

(or wherever you put your TrueType fonts), save and you're golden.  You may 
also want to prevent it from antialiasing certain font sizes.  For example, 
you can prevent it from antialiasing sizes between 8pt and 14pt by adding 
these lines to /etc/X11/XftConfig:

        any size > 8
        any size < 14
        antialias = false;


Vorbis 1.0RC2  (http://www.vorbis.com/)

Vorbis is a next-gen audio codec with much better quality than MP3 and no 
patent strings attached.  The libao, libogg and libvorbis packages are the 
minimal necessary, though you may want the vorbis-tools package if you want 
the command-line encoder and player.

Note on optimization:  libvorbis may cause a compiler error if compiled with 
-march=i686.  Tone down your CFLAGS and try again if this happens.

First build libao, then libogg, then libvorbis, each with the following 

  ./configure --prefix=/usr &&
  make &&
  make install


lame 3.89beta  (http://www.mp3dev.org/mp3/)

3.89 is the first version of LAME that creates a fully working shared lib.  
Older versions won't work.  It is recommended that if you have any intent to 
make MP3s that you install LAME - it is bar-none the best MP3 encoder there is.

Install LAME with these commands:

  ./configure --prefix=/usr &&
  make &&
  make install

You may see warnings during the configure about Vorbis not being found; don't 
worry because LAME only builds with Vorbis support using very old versions of 
the Vorbis libraries.


cdparanoia III alpha 9.8  (http://www.xiph.org/paranoia/)

cdparanoia is the best-known error correcting ripper in the Linux world, and 
is what KDE uses for ripping.

Install cdparanoia with these commands:

  ./configure --prefix=/usr &&
  make &&
  make install

This will set up both shared and static libs plus the command-line ripper.


lesstif 0.93.12  (http://www.lesstif.org/)

lesstif is an open version of the Motif toolkit, and is used by KDE for 
netscape plugin support in Konqueror.

Install lesstif with these commands:

  ./configure --prefix=/usr --disable-debug &&
  make &&
  make install


openssl 0.9.6b  (http://www.openssl.org/)

Openssl is an encryption library used by KDE for https:// support.  It is a 
part of the well-known OpenBSD project.  See the openssh.txt hint for 
instructions on how to install openssl.


KDE 2.2.1  (http://www.kde.org/)

KDE 2.2.x has been known to be problematic when compiled with -march=i686. 
Most notably, aRts tends to fail completely.  -O3 -march=i386 -mcpu=i686 seems 
to be far more reliable.

KDE2 usually goes into its own directory, most of the time /usr/local/kde2 or 
/opt/kde2.  I use the former.  Whatever you use, be sure to add the bin 
directory to your path and the lib directory to /etc/ld.so.conf.

Installing the KDE packages is straightforward.  First install kdelibs, then 
kdebase.  The rest can be done in any order.  Compile each package using these 

  ./configure --prefix=/usr/local/kde2 --disable-debug --enable-objprelink \
--enable-final &&
  make &&
  make install

Remove --enable-objprelink if you're not prelinking.  --enable-final is used 
because it tends to cut compile times by about 30-40% (from ~8hr to ~5.5hr for 
all packages on a 400MHz P2).  All optional packages you've installed will be 
automatically detected by the configure script.

If you want KOffice prelinked, you'll need the kde-admin-acinclude.patch from 
the objprelink page.  Also, you'll need to use autoconf 2.13 and automake 
1.4-p5 - newer versions of autoconf and automake will NOT work.  If you're not 
prelinking KOffice, you can use the same build instructions as for the other 
KDE packages.

Prelinkers can build KOffice with the following commands:

  cd koffice-1.1/admin &&
  patch -Np1 -i ../../kde-admin-acinclude.patch &&
  cd .. &&
  make -f Makefile.cvs &&
  ./configure --prefix=/usr/local/kde2 --disable-debug --enable-objprelink \
--enable-final &&
  make &&
  make install

Now add "exec startkde" to your ~/.xinitrc.

  echo "exec startkde" >> ~/.xinitrc

Congratulations!  You now have a brand-spanking new, highly optimized KDE 
2.2.1 installation waiting for you!  Run "startx" to fire it up and enjoy!

More information about the hints mailing list