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

    From KDE TechBase
    m (Text replace - "<code bash>" to "<syntaxhighlight lang="bash">")
    m (Text replace - "<code>" to "<syntaxhighlight lang="text">")
    Line 104: Line 104:
      else make install; fi;
      else make install; fi;


    If ./configure produces errors about missing headers, run the following command before trying again: <code>QTDIR=`pwd` bin/syncqt</code>
    If ./configure produces errors about missing headers, run the following command before trying again: <syntaxhighlight lang="text">QTDIR=`pwd` bin/syncqt</code>


    '''Make sure <tt>which qmake</tt> delivers something out of $QTDIR, e.g.:'''
    '''Make sure <tt>which qmake</tt> delivers something out of $QTDIR, e.g.:'''

    Revision as of 20:46, 29 June 2011


    Getting_Started/Build/KDE4/Prerequisites


    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.


    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
    

    秘诀

    Tip
    请确认你的环境已按照上面的叙述正确配置。这对cscb函数的正确运行是必须的。


    <syntaxhighlight lang="bash"> 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构建服务提供的。

    秘诀

    <syntaxhighlight lang="bash"> 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

    接下来我们需要取得 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://gitorious.org/+kde-developers/qt/kde-qt.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: <syntaxhighlight lang="text">QTDIR=`pwd` bin/syncqt

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

    /home/kde-devel/qt-kde/bin/qmake
    

    发生了什么

    我们切换回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

    Tip
    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.

    kdesupport

    Warning
    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://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://...'
    

    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 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]]