Archive:Getting Started/Build/KDE4/Prerequisites (zh CN)

Template:TutorialBrowser (zh CN)


部分或所有这些套件应该可以从您的发行版安装。如果提供够新的版本,安装发行版套件是一个不错的主意;可以方便安装和升级。建构 KDE 4 的软件须求包括:

  • gcc and g++, preferably version 4.2 or higher
  • svn, the subversion revision control client
  • pkg-config
  • development libraries and headers for X11, OpenGL (mesa-common-dev and libglu1-mesa-dev), libjpeg, libpng, libungif, libclucene, librdf, libxml2 and libxslt
  • the makeobj script, which is included in kdesdk. You can install it from kdesdk (kdesdk-scripts on Debian) or similar packages, or download at WebSVN
  • the shared-mime-info package, is the freedesktop MIME standard now used in KDE
  • boost, used by kdebase; after build and/or install, in order to make cmake aware about its location (FindBoost), add the boost directory (which contains the include subdirectory) to CMAKE_INCLUDE_PATH or set a environment variable called BOOST_ROOT that points to the boost directory.





Building X11 code:        yes



tar -xvzf dbus-1.0.2.tar.gz
cd dbus-1.0.2/
./configure --prefix=$DBUSDIR --localstatedir=$KDEDIR/var
make install
dbus-uuidgen --ensure



注意,最后两步,你需要有对/var的写入权限,如果你的系统不支持sudo,你可以使用su命令代替。例如:su -c "make install"


If you get the error: "configure: error: DBus development libraries not found" do this: export PKG_CONFIG_PATH=/lib/pkgconfig/




tar zxf cmake-2.4.6.tar.gz
mkdir cmake-build
cd cmake-build
sudo make install



如果你的系统没有sudo命令,可以使用su -c "make install"命令代替。


接下来我们需要取得 Qt 4。KDE 4.3 的建构倚靠 Qt 4.5,但是 KDE trunk 需要 Qt 4.6。如果你计划持续的建构 trunk,kde-qt 可能更容易追踪,尤其是 KDE trunk 有时可能需要正式发行前的 Qt 版本。

大部分最新的发行版将有足够新的 Qt 套件去建构最新的 KDE 稳定分支。一些发行版甚至有 kde-qt 套件;如果有,使用它是一种可行的选择。如果您使用的发行版不提供需要的 Qt 版本,就必须使用下面的方法。更多信息可在针对发行版的教学章节找到。

Building qt4.4 with the -no-qt3support option will cause things to break.

Please read the README.kde-qt file for the necessary Qt configure options as well as currently known issues.


cs    # Note: cs is not a typo. See  .bashrc 
git clone git:// qt-kde
cd qt-kde
./configure [copy/paste configure line from README.kde-qt replacing <installdir> with $QTDIR]
make -j2 # use 'make -j(X+1)' where X is your number of processors, to compile faster
# if we don't install, we'll just clear obj files to
# save disk space
if [ "$QTDIR" = "`pwd`" ]; then \
find . -name '*.o' -delete ; \
else make install; fi;

If ./configure produces errors about missing headers, run the following command before trying again:

QTDIR=`pwd` bin/syncqt

Make sure which qmake delivers something out of $QTDIR, e.g.:







如果你得到了“error: X11/Xlib.h: No such file or directory”,请安装xorg(实际的名称可能根据操作系统的不同而改变,例如在基于Ubuntu的系统Kubuntu上,这个包叫xorg-dev)的开发包。

如果你在configure时获得缺失定义的错误,请检查$QMAKESPEC的值。一些发行版将这个值设置为系统安装的Qt,如果unset QMAKESPEC可以解决这个问题,你可能希望把它添加到~/.bashrc脚本中。

如果你得到错误“.pch/debug-shared/QtCore”,这是因为Qt 4.3激活了你的gcc所支持的一些预编译头文件,但因为一些原因它不能为你工作。如果你使用distcc,使用-no-pch来配置Qt。如果你使用icecream,请从其svn主分支升级到最新版本。

如果你的gcc支持,Qt4.3允许使用预编译的头文件,但因为某些原因它不工作。如果你使用distcc,使用 -no-pch来configure Qt.如果你使用icecream,从svn上升级到最新的版本。


Generating local API documentation

It's nice to have the Qt documentation locally for nice integration with KDevelop, and doing this is really quite easy (also shown in README.kde-qt):

cd $KDE_SRC/qt-kde
make docs
make install

Note that it is necessary to do this only once, even if you rebuild Qt later.


You can use qdbusviewer to see if you have org.freedesktop.hal. If not, you might need a newer version of hal. If you have org.freedesktop.hal, you probably don't need to, and don't want to, roll your own HAL.

If your system requires you to build a newer version of HAL, there's a decent chance you'll need to build other stuff as well, some of which may not be straight forward. This, however, should only be required for older distros.


Don't forget to read the Setting Up The Environment section first.

There are several libraries that KDE applications rely on in the kdesupport module. This includes Phonon, Strigi and Soprano for file metadata and search, QImageBlitz for image manipulation needed in kdebase, eigen for visual effects in applications such as Kalzium, taglib for music players and qca for some cryptographic needs.

Strigi itself has a few dependencies as well: you will need the libraries and headers for libz, libbz2, openssl (libcrypto or libssl), libclucene (>=0.9.16a but watch out: version 0.9.17 does not work), and either libxml2 or libexpat.

Please remember that if you use openSUSE, you can install the needed packages from the KDE:KDE4 buildservice repository and do not have to bother with fiddling the details below. Skip to the kdelibs section.

The Recipe

cs # 'cs' is a bash function, click here to learn more
svn checkout svn://
cd kdesupport

What's Happening

We change to the base source directory (line 1). We download the sources in kdesupport using subversion (line 2), go into the new ~/kde/src/kdesupport directory (line 3), and commence the build (line 4). This will leave us in the kdesupport build directory after the build is completed.


If you get

  cmakekde: command not found

then you have to go manually into the kdesupport directory in ~ and execute the command cmakekde. if this still doesn't work, then something is wrong with your bashrc.

If you get

CMake Error: This project requires some variables to be set,
and cmake can not find them.
Please set the following variables:

you should install the development package for libxml2.

If you get

CMake Error: Could NOT find REDLAND

then you need librdf from the Redland. If your distribution does not provide the librdf package, you can download the source there: and build it. (Gentoo users: The ebuild for librdf is named dev-libs/redland)

If you get

Fetching external item into 'kdesupport/admin'
Error validating server certificate for 'https://...'

see Using Subversion with KDE

If you get

FILE cannot create directory: /usr/lib[64]/qt4/plugins/crypto. Maybe need administrative privileges.

make: *** [install] Error 255

take a second look in the .bashrc file described above, are paths correct? ($QTDIR and $PATH are used to get the QT installation path) Alternatively, you may see this error if you decided to use a distribution installed version of qt4 and skipped the Qt install above. Either install qt-kde as describe above, or "sudo make install". If you use "sudo make install", make sure that you change the ownership back to your user for some of the ~/kde subdirectories that were effected by using sudo (ie. "sudo chown -R kde-devel:kde-devel ~/kde").

If you get a message related to

  target not found

you may need to recompile qt-kde. This time you should take out

  -nomake demos -nomake examples

from the configure command, so that Qt generates library QtTest.

If you get

     CMake Error: Qt qmake not found!


     1) uncomment Qt section in .bashrc script (QTDIR, QT_PLUGINS_DIR,      
           PKG_CONFIG_PATH variable settings).
     2) source ~/.bashrc
     3) cd && cd qt-kde
     4) make confclean
     5) repeat steps for installing Qt (from ./configure line).
     6) retry building kdesupport

If you get

     "CMake Error: Could NOT find BZip2"


     sudo apt-get install libbz2-dev


     urpmi libbzip2_1-devel

If you get

     message that MySql support cannot be enabled


     you need to install corresponding devel package. (libmysqlclient-devel  for SuSe 11.1)

Next Step

Once all requirements have been installed it is time to install [[../#kdelibs|kdelibs]]

This page was last edited on 23 June 2013, at 13:32. Content is available under Creative Commons License SA 4.0 unless otherwise noted.