How to get KDE2 and KDE3 (from cvs) working on the same machine

Introduction

This paper aims to help new KDE developers to install KDE3 from cvs on their machine without interfering with their KDE2 installation and thus allow them to port their code.
Advanced Linux users who want to help debugging or just taste new features can also benefit from this tutorial.

I explain (in great details) how to get, compile and install KDE3 from cvs and to get it work smoothly along with your existing KDE2.
One way to do it is to follow the link: http://www.kde.org/kde2-and-kde3.html

Another way is to create a new user for KDE3 (I find it is better with dcop). When you log in your normal user, you get your actual KDE2 and when you log in your new user (called here kde3) you'll be on KDE3 cvs.
That's the way I explain here.

The trick here is not to install the new KDE from cvs on the actual KDE. If kde-cvs is NOT compiled as root, this cannot happen and you are safe!

What you need to know before starting: we will get all KDE3 sources from cvs and you need space on your disk. Qt-copy uses 120Mb and kdesupport, kdelibs and kdebase (which are the minimum) ask for 500Mb space disk. The other modules are not so big and use another 100Mb altogether.
As I propose to compile kde in the new kde3 user dir, see if you get enough space to do that on your /home partition. Alternately you can choose /opt/kde3 for the compiling. We'll install KDE3 in /usr/local/kde3.

Compiling qt-copy from cvs

You can use your user for compiling qt3.
If you had never used cvs before, you need to create a special file with parameters in your home (one in your user home and one later in the kde3 user home)
[ann@localhost ann]$ vi .cvsrc 
and the file .cvsrc should have these 4 lines:
cvs -z4
diff -u
update -dP
checkout -P
Don't forget to save it.

Getting qt-copy from cvs

You need first to get qt-copy from cvs and to compile it You can do that as your usual user.
[ann@localhost ann]$ cd /usr/local/
If your user has not the adequate permissions for /usr/local, then change the permissions as root.
[ann@localhost local]$ export
 CVSROOT=:pserver:[email protected]:/home/kde
[ann@localhost ann]$ cvs login
(enter as password)
[ann@localhost local]$ cvs co qt-copy
You'll see a lot of lines writing in the terminal.
When you get the prompt back, then the cvs checkout is finished, you need to compile.

Compiling qt-copy

Before compiling, you need to set up a few environment variables:
[ann@localhost local]$ cd qt-copy
[ann@localhost qt-copy]$ export YACC='byacc -d'
[ann@localhost qt-copy]$ export QTDIR=$PWD
[ann@localhost qt-copy]$ make -f Makefile.cvs
[ann@localhost qt-copy]$ ./configure -system-zlib -qt-gif -system-libpng -system-libjpeg -plugin-imgfmt-mng -thread -no-stl -no-xinerama -no-g++-exceptions
(you'd better copy/paste that one to get it right)
[ann@localhost qt-copy]$ make
No need to install qt. If all went well, you should have qt3 on your machine.

Compiling KDE3 from cvs

Create the new kde3 user

As root:
[root@localhost ann]# adduser -m kde3
(don't forget the -)
[root@localhost ann]# passwd kde3
(enter the same password twice)
We'll install cvs in /usr/local/kde3, a new dir in which we give the usr kde3 the write permission.
Still as root:
[root@localhost ann]# mkdir /usr/local/kde3
[root@localhost ann]# cd /usr/local/kde3
[root@localhost kde3]# chown kde3:kde3 .
(don't forget the dot)
You can now exit root by typing
[root@localhost kde3]# exit

Setting up the environment variables for the new user

Now, for KDE-cvs, we log in as kde3 user to be sure we won't interfere with the existing kde2.
[ann@localhost ann]$ su - kde3
(watch the -)
Password:
you type in the kde3 user password.

Edit the file .bash_profile in /home/kde3 and add the following lines:
export KDEDIR=/usr/local/kde3
export QTDIR=/usr/local/qt-copy
export MANPATH=$QTDIR/doc/man:$MANPATH
export PATH=$QTDIR/bin:$KDEDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export CVSROOT=:pserver:[email protected]:/home/kde

You also have to create the .cvsrc file for the kde3 user:
[kde3@localhost kde3]$ vi .cvsrc
and add the 4 lines given previously (diff -u....).
Logout as kde3, login as root.
[kde3@localhost kde3]$ exit
[ann@localhost ann]$ su
(password)
Edit the file /etc/ld.so.conf and add these two lines:
/usr/local/qt-copy/lib
/usr/local/kde3/lib
Re-log as kde3 (note that all those variables setup are a one-time hassle only!)
[ann@localhost ann]$ su - kde3
Password:
This is for the new variables to be recognized. Each time you'll log in kde3, these variables will be set up.

You can check that your variables are correct by typing:
[kde3@localhost kde3]$ set |grep KDEDIR
The output should be
KDEDIR=/usr/local/kde3
[kde3@localhost kde3]$ set |grep QTDIR
QTDIR=/usr/local/qt-copy

Getting and compiling kde, at last!

We will get first kdesupport which gives you the latest libxml libs which are needed.
You must be logged in as the kde3 user.
[kde3@localhost kde3]$ mkdir cvs-kde
[kde3@localhost kde3]$ cd cvs-kde
[kde3@localhost cvs-kde]$ cvs login
(enter as password)
[kde3@localhost cvs-kde]$ cvs co kdesupport 
[kde3@localhost cvs-kde]$ cd kdesupport
[kde3@localhost kdesupport]$ make -f Makefile.cvs
[kde3@localhost kdesupport]$ ./configure
[kde3@localhost kdesupport]$ make
[kde3@localhost kdesupport]$ make install


If you get a compile error that you cannot resolve (i.e if you are sure you don't miss a devel package), you can re-run the compile by:
make -i
make -i install
Be aware that you should try to resolve any compile error by checking your system and enquiring on IRC for example for known bugs because you can later miss an important lib that will not be compiled.

Please check that the installed files go to the /usr/local/kde3 dir.
[kde3@localhost kdesupport]$ ls -l $KDEDIR/lib
[kde3@localhost kdesupport]$ ls -l $KDEDIR/include
You should have some output like that:
lrwxrwxrwx    1 kde3     kde3           16 Dec  7 18:35 libxslt.so
 ->libxslt.so.1.0.7*
If this is the case, then you can use
su -c 'make install'
for installing the files as some requiert that (like kppp for example).

You then repeat the procedure for kdelibs, kdebase and all the modules you want to try. Please note that kdesupport then kdelibs are to be compiled in that order.
The command
cvs co -c
gives you a list of all the modules available.

If something went wrong and you want to start again to compile a module, you have to run:
make clean 
rm config.cache
before re-starting with
make -f Makefile.cvs .....

When you have finished with kdesupport, kdelibs and kdebase, you can try the new KDE by getting to your graphical login and use the kde3 user to start kde. You will see the new splashscreen at first. If not, then one of your variables must be incorrect.

Note for Suse users: in /home/kde3/.xinitrc, replace the line
exec $WINDOWMANAGER
by
/usr/local/kde3/bin/startkde

Accessing a KDE3 program from your KDE2 user

If you are logged as your KDE2 user, you still can launch a KDE3 program. The program will then run as in KDE3 but on the KDE2 environment.
You open a terminal and type as the KDE2 user:
[ann@localhost ann]$ xhost+localhost
[ann@localhost ann]$ su - kde3
Password:
[kde3@localhost kde3]$ export DISPLAY=:0.0
[kde3@localhost kde3]$ the name of the KDE3 program

Thanks to Olaf Zanger for testing and helping to improve the document.

Anne-Marie Mahfouf
(c)2001

From original french docs by François-Xavier Duranceau (KDE1+2) and Hervé Lefebvre.
You can find a similar document in french at http://www.kde-france.org/article.php3?id_article=17

Anne-Marie Mahfouf got to know Linux only three years ago with a free CD in a magazine. After a while she joined the KDE translation team to help translating docs into French. I also started programming with Qt/KDE, painfully at first as she had no programming knowledge at all. The KDE community has been very important for its help and support.

Last July she initiated KDE-Edu which aims to develop educational software. The project was officially launched in September and is now very active (website: http://edu.kde.org). Being herself quite a "newbie", she likes writing docs that help beginners.

On a more personal note, she is the mother of four children aged 15 to 3 1/2 years old. She is French but lived in England since 1995. She enjoy playing music, and like reading, she trys to practice a sport regularly!

Anne-Marie Mahfouf could be reached by email: [email protected]