Saturday, April 17, 2010

Quick Compiling Kate in a stable KDE Environment

Since all of the Kate code is now co-hosted on gitorious, it became very easy to build Kate in your stable KDE >= 4.4 environment. This means you can run the newest version of Kate with very few effort. Just give it a try and do the following steps:
  1. make sure you have the following packages installed: git, cmake and kdelibs development package (on openSUSE this is git, cmake and libkde4-devel)
  2. create and change into a KDE development directory:
    mkdir ~/kde; cd ~/kde
  3. get a copy of the Kate code:
    git clone git://gitorious.org/kate/kate.git
  4. create and change into a build directory for compilation:
    mkdir build; cd build
  5. run the configure process with cmake:
    cmake ../kate -DCMAKE_BUILD_TYPE=fulldebug \
    -DCMAKE_INSTALL_PREFIX=~/kde/usr
  6. compile Kate:
    make
  7. finally install Kate:
    make install
That's all! This installs Kate locally into the separate directory ~/kde/usr, so that your global KDE installation will not be touched at all.

Now on to starting the newly compiled Kate. Create a file ~/kde/run.sh with the following content:
#!/bin/bash
export KATE_DIR=~/kde/usr

export PATH=$KATE_DIR/bin:$PATH
export LD_LIBRARY_PATH=$KATE_DIR/lib:$LD_LIBRARY_PATH
export KDEDIR=$KATE_DIR
export KDEDIRS=$KDEDIR
export XDG_DATA_DIRS=$XDG_DATA_DIRS:$KATE_DIR/share
# update KDE's system configuration cache
kbuildsycoca4
# start app
$@
Now you can run the compiled Kate version with ~/kde/run.sh kate. Just calling kate directly will start the system version of Kate.

Your copy of Kate contains all of the Kate code, i.e.: the KTextEditor interfaces, Kate Part, KWrite and the Kate Application. Feel free to send patches to our mailing list kwrite-devel@kde.org. And join #kate on irc.kde.org :-)

Note for KDE developers: All the changes in git are merged back to KDE's subversion repository in a timely manner. So don't worry about Kate moving away from KDE; this is not the case.

(Updated on 2010-04-17: Allow installation into local directory.)

16 comments:

eMerzh said...

On my ArchLinux i have a CMake Error at app/CMakeLists.txt:33 (kde4_add_library):
Unknown CMake command "kde4_add_library".

I there a howto "How to Compile Kate for testing purpose" ( and not for installing) ?

Thanks for your help

Unknown said...

This is because you're trying to run cmake at the kate/app CMakeLists.txt, but you must do it in the one which is at the root directory.

zak89 said...

Cool! I just got my fresh new Kate running! One quick question - I now have no (0) plugins - no Filesystem Browser, to Tab bar, nothing. Where do I find these now?

dhaumann said...

@eMerzh: When you call cmake ../kate, the directory ../kate must be equal to kde/kate. Maybe yours is kde/kate/app?

You can install it locally by creating a new user and then install it into your `kde4-config --localprefix` directory. This way you surely won't touch your working user account.

@zak89: Mh, try to run kbuildsycoca4 to update KDE's system configuration cache. Does that help?

zak89 said...

Hmm... Running kbuildsycoca4 dosen't seem to make a difference.

I should note that i uninstalled the system version of Kate before installing the git version. Is that a problem?

dhaumann said...

No, should not be a problem. I'll provide a solution later or tomorrow.

Unknown said...

@zak89: you probably need to set KDEDIRS properly, so the plugins are found correclty.

If Kate also installs XDG_DATA stuff (I think some icons?), you'll have to setup XDG_DATA_DIR and XDG_CONFIG_DIR (or was it _DIRS) appropriately as well.

Take a look at how I do it at:

http://github.com/milianw/shell-helpers/blob/master/kde4_setup_build_environment.sh

zak89 said...

Thanks guys, it seems to be working now - strangely a reboot seemed to fix the issue.

BTW, recently someone on the planet posted a patch for a new Tab bar plugin - does anyone know who/where this came from? Now that I have Kate installed from source I'd like to try it out.

vivo said...

for gentoo users something like this should work

cmake -C gentoo_common_config.cmake -DCMAKE_INSTALL_PREFIX=$HOME/usr -DWITH_plasma=ON -DWITH_PLASMA=ON -DWITH_Plasma=ON -DCMAKE_BUILD_TYPE=Debugfull -DCMAKE_INSTALL_DO_STRIP=OFF -DCMAKE_USER_MAKE_RULES_OVERRIDEgentoo_rules.cmake ..

where gentoo_common_config.cmake contains:
SET (LIB_SUFFIX 64 CACHE STRING "library path suffix" FORCE)
SET (CMAKE_INSTALL_LIBDIR lib64 CACHE PATH "Output directory for libraries")
SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)

and gentoo_rules.cmake
SET (CMAKE_C_COMPILER /usr/bin/x86_64-pc-linux-gnu-gcc CACHE FILEPATH "C compiler" FORCE)
SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
SET (CMAKE_CXX_COMPILER /usr/bin/x86_64-pc-linux-gnu-g++ CACHE FILEPATH "C++ compiler" FORCE)
SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)

better, do it yourself, start an emerge of kate, stop it with ^C after it did ran cmake and analize ;)

vivo said...

now I've another problem:
lsof | grep " $(pidof kate) " | grep '/usr/lib64/kde4/'
show that a bunch of .so used are still from system kde.
LD_PRELOAD does not help, what to do?

dhaumann said...

Can you try with the current suggestion of the run.sh script?

Unknown said...

KATE_DIR is set up with /usr at the end. This makes PATH, LD_LIBRARY_PATH and KDEDIR have a ~kde/usr/usr portion which does not work.

dhaumann said...

Travis: Thanks, fixed.

Anonymous said...

This post is now for the twelfth time on planetkde. Can you please make sure it does not show up there again?

dhaumann said...

@toma: How? I'm simply fixing typos or other bugs in the howto, and click publish... How can I tell to not update the index again?

Akregator does not show it again, btw.

chandra said...

On Kubuntu Lucid with packages from kubuntu:ppa I had problems with the Spellchecker swalloing up adjacent words.

So I installed git-core cmake and kdelibs5-dev.

I then followed the instructions to install kate from git to the letter, and voila! I had a flawless kate experience. Spellcheck works perfectly now.

Thank you Dominik Haupmann.