Archive:Getting Started/Build/KDE4/Prerequisites (zh CN)
Getting_Started/Build/KDE4/Prerequisites
Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
Tutorial Series | Getting Started |
Previous | [[../|KDE SVN Quickstart Guide]] |
What's Next | [[../|KDE SVN Quickstart Guide]] |
Further Reading | n/a |
Abstract
Some or all of these packages should be available for installation from your distribution. For ease of installation and upgrading it is a good idea to install distribution packages if a recent enough version is provided. Software required to build KDE4 includes:
- 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.
D-Bus
QtDBus和KDE使用的D-Bus版本为0.62、0.92或更高的版本。0.60和0.61版可能也行但未经测试。0.90和0.91版不能工作。我们建议使用1.0版(最低0.94),所以如果你还没有该版本,请考虑升级。
如果你已经使用了最新的D-Bus版本或者根本不想升级,可以跳过这一节。
在运行秘诀中的步骤之前,请确认你有X11的头文件和库文件。配置脚本的第五行应该输出:
Building X11 code: yes
秘诀
cs
wget http://dbus.freedesktop.org/releases/dbus/dbus-1.0.2.tar.gz
tar -xvzf dbus-1.0.2.tar.gz
cd dbus-1.0.2/
./configure --prefix=$DBUSDIR --localstatedir=$KDEDIR/var
make
make install
dbus-uuidgen --ensure
发生了什么
在切换到源码目录后(第1行),从freedesktop.org下载D-Bus的源代码(第2行)并解压缩(第3行)。在进入新创建的D-Bus目录后(第4行),通过提供的configure脚本准备构建(第5行)。在完成D-Bus的构建(第5行)和安装(第7行)后,使用dbus-uuidgen工具来安装机器识别文件,该文件使得D-Bus在桌面启动时自动运行(第8行)。
注意,最后两步,你需要有对/var的写入权限,如果你的系统不支持sudo,你可以使用su命令代替。例如:su -c "make install"。
Troubleshooting
If you get the error: "configure: error: DBus development libraries not found" do this: export PKG_CONFIG_PATH=/lib/pkgconfig/
CMake
如果你的CMake>=2.4.5,那请跳过这一节。你可以直接使用CMake网站提供的二进制包。这里有针对一些发行版特定的安装包。针对openSUSE的CMake二进制包是由openSUSE构建服务提供的。
秘诀
cs
wget http://www.cmake.org/files/v2.4/cmake-2.4.6.tar.gz
tar zxf cmake-2.4.6.tar.gz
mkdir cmake-build
cd cmake-build
../cmake-2.4.6/bootstrap
make
sudo make install
发生了什么
首先,我们回到kde-devel用户的源码目录(第1行),获取CMake的源码(第2行)并解压(第3行)。然后创建一个CMake的构建目录(第4行)并进入该目录(第5行)。通过运行CMake的boostrap脚本来准备CMake的构建(第6行),然后以root身份编译(第7行)并安装(第8行)CMake。
如果你的系统没有sudo命令,可以使用su -c "make install"命令代替。
Qt
下一步,我们需要从KDE的代码仓库获得Qt4。KDE保证可以依赖任何版本的Qt 4.3来构建。Qt 4.2和之前的版本将不被支持且无法工作。Qt 4.3尚未发行,因此不一定有针对你的发行版的预编译包。你应该使用KDE Subversion服务器提供的代码副本。
秘诀
cd
svn checkout svn://anonsvn.kde.org/home/kde/trunk/qt-copy
cd qt-copy
./apply_patches
./configure -qt-gif -no-exceptions -debug -fast \
-prefix $QTDIR -qdbus -pch -nomake examples \
-nomake demos
make sub-src sub-tools
- make install: 当且仅当 QTDIR 不是当前目录!
make install
发生了什么
我们切换回kde-devel用户的主目录(第1行),然后使用subversion(svn)从KDE的代码仓库下载源代码(第2行)。在切换进入qt-copy目录后(第3行),我们运行qt-copy下脚本来管理补丁(第4行)。
当这些补丁被应用后,我们使用configure脚本准备构建环境(第5-7行),这里使用的几行命令和选项在qt-copy/README.qt-copy文件里有解释。最后,编译我们构建KDE所需的最少需求组件(第8行)并安装Qt(第9-10行)。如果想要全部的例子和demo应用,你可以单独构建他们或直接在qt-copy目录下运行make。
注意这次安装并不需要root,因为它把Qt安装到了本地的$QTDIR。所以,这次安装只要$QTDIR和$HOME/qt-copy不同即可,如果你已经遵循并执行了上面的指令,就不会出现这种情况。
疑难解答
如果你得到了“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上升级到最新的版本。
尝试运行一些Qt程序,比如assistant。如果它在QSpanData::adjustSpanMethods崩溃,那你可能使用了oxygen风格。尝试删除/lib/kde4/plugins/styles/kstyle-oxygen.so和/lib/kde4/plugins/styles/oxygen.so。当然,如果它们存在的话。
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 ./config.status make install
Note that it is necessary to do this only once, even if you rebuild Qt later.
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.
kdesupport
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://anonsvn.kde.org/home/kde/trunk/kdesupport/ cd kdesupport cmakekde
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.
Troubleshooting
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: LIBXML2_INCLUDE_DIR (ADVANCED)
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: http://download.librdf.org/source/ 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://...'
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 libQtTest.so 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!
Then:
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"
then
sudo apt-get install libbz2-dev
or
urpmi libbzip2_1-devel
If you get
message that MySql support cannot be enabled
then
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]]