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 | Українська | 简体中文 | 繁體中文
| Serie do tutorial | Empezando... |
| Prerequerimentos | Guía de consulta rápida do SVN anónimo |
| Seguinte | Configurar KDE 4 para desenvolvimento |
| Máis información | kdesvn-build: Ferramenta para a compilación de KDE dende Subversion Productividade mellorada con guións de shell en KDE 4 Introdución a CMake Notas sobre FreeBSD Instrucións para Mac OS X Instrucións para MS Windows |
Este tutorial mostra un xeito de obter KDE dende o trunk, usando sistemas baseados en Linux ou BSD. Hai tamén tutoriais para FreeBSD, Windows, Mac OS X e Solaris. Ao longo do tutorial será usada intensivamente un terminal de tipo bash.
| Os luns córrese un maior risco de erros na compilación, pois é cando se suben os cambios nas kdelibs. O dashboard avisa desas rupturas imprevistas. Animámosche a corrixir os módulos que faien. |
|---|
| Atención |
O seguinte debe estar instalado no teu sistema para poder rematar este manual de xeito satisfactorio:
En Ark Linux, as dependenzas para a compilación instálanse asi:
apt-get install devel-core libxml-devel libxslt-devel bzip2-devel \
clucene-devel librdf-devel shared-mime-info xorg-Mesa-libGL-devel \
subversion boost-devel doxygen giflib-devel dbus-devel openssl-devel \
alsa-lib-devel kdesdk-scripts qt4-devel
Se prefires unha interface gráfica, selecciona os pacotes listados enriba na ferramenta de "Install Software" no Mission Control. Isto inclue a instalación de CMake, DBus e Qt, polo que podes pasar dos pasos 5, 6 e 7.
En Kubuntu 7.04 (Feisty) (e, posibélmente 7.10) as dependencias para a compilación que tes que ter instaladas fanse asi:
sudo aptitude install build-essential cdbs debhelper cmake \
libxml2-dev libxslt1-dev libbz2-dev libclucene-dev librdf-dev \
shared-mime-info libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev \
libxext-dev libjpeg-dev libpng-dev subversion libsm-dev libxinerama-dev \
libxrender-dev libfontconfig-dev libboost-dev libxcursor-dev doxygen \
libungif4-dev libdbus-1-dev libgpgme11-dev libssl-dev libgpgme11-dev \
libasound2-dev kdesdk-scripts
Podes evitar a instalación manual de CMake 2.4.6 e DBus facendo:
sudo aptitude install libdbus-1-dev cmake
Para ter un framework completamente funcional para a documentación do API tamén precisarás:
sudo aptitude install graphviz
En openSUSE 10.2 e posteriores, podes instalar pacotes usando a ferramenta Zypper:
sudo zypper install <package-name>
En versións vellas de SUSE, podes usar YaST:
su
yast -i <nomepacote>
Pacotes precisos
Os pacotes que precisarás instalar son os seguintes:
xorg-x11-devel
libxml2-devel
kdesdk3
clucene-core-devel
boost-devel
libjpeg-devel
liblrdf-devel
libpng-devel
libxslt-devel
libredland-devel
Mesa-devel
giflib-devel
subversion
gcc
gcc-c++
Pacotes opcionais
Podes saltar a instalación de Qt 4.3, CMake 2.4.6 e DBus engadindo o repositorio do Servizo de Compilación de KDE 4 de openSUSE (openSUSE Build Service KDE4 Repository) ás tuas fontes de compilación.
Para openSUSE 10.2 e superior fai:
sudo zypper service-add http://software.opensuse.org/download/KDE:/KDE4/openSUSE_10.2 KDE4-102
Para versións antigas de SUSE Linux fai:
su
installation_sources -a http://software.opensuse.org/download/KDE:/KDE4/[A TÚA VERSIÓN DE SUSE]
Agora instala os seguintes pacotes (e as suas dependencias):
cmake
dbus-1-devel
libqt4-devel
Para ter un framework completamente funcional para a documentación do API tamén precisarás:
graphviz
Pacotes cos binarios de CMake para openSUSE están disponíbeis no servizo de compilación de openSUSE.
Para ter as ebuilds máis estábeis lembra sincronizar a árbore de portage antes de comezar.
Precísase que estean unmasked e/ou mantidas(kept) nunha versión anterior para continuar.
Comproba que tes activada a bandeira berkdb USE para redland, ou nepomuk non funcionará:
Estes son os pacotes que tes que instalar, moitos deles xa estarán instalados no teu sistema, polo que podes saltalos engadindo a bandeira de update en emerge.
$ emerge -avu ebuild/name
sys-devel/gcc dev-util/subversion dev-util/pkgconfig x11-base/xorg-x11 media-libs/glut media-libs/mesa media-libs/jpeg media-libs/libpng media-libs/giflib dev-cpp/clucene dev-util/cppunit media-libs/liblrdf dev-libs/libxml2 dev-libs/libxslt x11-misc/shared-mime-info kde-base/kdesdk-scripts dev-libs/boost x11-libs/qt dev-util/cmake sys-apps/dbus dev-libs/redland
Supondo que emergeaches esas ebuilds, podes saltar os pasos de compilación a man e proceder á sección de kdesupport.
Boa sorte!
Podes instalar os pacotes de KDE4 directamente via:
emerge -a <packagename>
Para conseguir as cousas que precisas, install layman e and then pull in the KDE overlay (que contén ebuilds experimentais de KDE):
layman -a kde
Logo disto precisas axustar algunhas bandeiras USE KDE 4 e dicirlle a portage que use as ebuilds de proba de KDE 4 en lugar das estábeis de KDE 3.
Deste xeito portage encargarase das dependencias por ti.
Instrucións detalladas sobre compilar KDE 4 en Gentoo via portage podes atopalas no wiki de overlay sobre KDE. Tamén fálase no fío: KDE 4 monolithic ebuilds.
|
Algunha xente usa contas de usuário separadas para KDE 4 (por se, por exemplo, un bug elimina arquivos por erro), as instrucións a seguir están escritas segundo esa aproximación. Sen embargo, é moito máis eficiente ter todo nunha simple conta de usuario, bótalle unha ollada a Productividade mellorada con guións de shell en KDE 4 para máis detalles. De todos os xeitos, podes seguir as instrucións de abaixo, pero non poñas variábeis de entorno no teu .bashrc, ponas nun arquivo separado das tuas fontes para intercambialo co entorno de KDE 4. |
|---|
| Nota |
useradd -m kde-devel
passwd kde-devel
No canto de usar os comando de enriba, podes usar o módulo de usuario do Centro de Control de KDE, se xa tes instalado KDE 3.
Copia o ~/.bashrc do teu usuario normal á nova conta de kde-devel. De seguir, copia e pega os contidos do .bashrc de exemplo en ~kde-devel/.bashrc. Asegura-te de comentar a liña alias make=makeobj se non tes o comando makeobj disponíbel. Posíbelmente querrás modificar o path (camiño) para ter seguro que non inclue os paths do teu KDE3. Para facelo executar, tes que ter aberta unha nova bash ou executar:
source ~/.bashrc
Isto proporcionará aceso aos comandos como cmakekde que son usados ao longo deste tutorial asi como asegurará que os paths aos binarios de Qt, KDE e CMake están correctamente.
Para máis información, bótalle unha ollada ao tutorial de Productividade mellorada con guións de shell en KDE 4.
Para usar o novo usuário kde-devel: (non esquezas o guión)
su - kde-devel
Algúns sistemas están configurados para que os novos usuarios usen /bin/sh por defecto. Se non é o caso no teu podes saltarte esta sección (por exemplo se usas Ark Linux). Traballar con /bin/sh pode ser moi inconvinte, probablemente queras cambiala a /bin/bash ou outra consola.
Se non tes privilexios de root e o teu sistema soporta o cambio da túa propia consolo co comando chsh, podes cambiala a /bin/bash con:
chsh -s /bin/bash kde-devel
Se o teu sistema inclúe o comando usermod podes executa-lo seguinte coma root:
usermod -s /bin/bash
.
Outra opción é executa-lo comando vipw coma root para editar /etc/passwd de forma segura. Procura 'kde-devel' no arquivo e cambia '/bin/sh' no final da liña por '/bin/bash', garda os cambios e sae.
Poderás usa-la nova consola cando voltes a entrar coma usuario kde-devel.
QtDBus e KDE funcionan coas versións de D-Bus 0.62, 0.92 e posteriores. As versións 0.60 e 0.61 tamén poderían funcionar, aínda que non foron probadas. As versións 0.90 e 0.91 non funcionan. Recomendamos usar versións posteriores á 1.0 (polo menos 0.94), considera actualizar se aínda non o fixeches.
Podes salta-la seguinte sección se tes unha versión de D-Bus suficientemente recente ou non desexas actualizala.
Antes de continuar asegúrate ter cabeceiras e bibliotecas X11 dispoñibles. A quinta liña do guión de configuración das seguintes instruccións debería ler:
Building X11 code: yes
| Non esquezas configura-lo entorno adecuadamente, tal coma se describiu na sección Configurando o entorno. É preciso para que as funcións cs e cb funcionen. |
|---|
| Consello |
cs # 'cs' é unha función bash, prema aquí para saber máis 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=/var make sudo make install sudo dbus-uuidgen --ensure
Tras cambiar ó directorio das fontes (liña 1) descárgase o código de D-Bus dende freedesktop.org (liña 2) e descomprímese (liña 3). Éntrase no directorio de D-Bus recén creado (liña 4) e configúrase á construcción usando o guión configure (liña 5). Unha vez D-Bus está construído (liña 6) e instalado (liña 7) usamo-la utilidade dbus-uuidgen para instalar un arquivo de identificación de máquina que permite executar D-Bus automáticamente ó comezo da sesión de escritorio (liña 8).
Ten en conta que precisas ter permisos de escritura en /var para os dous últimos pasos. Se o teu sistema non posúe o comando sudo podes usar su no seu canto, por exemplo su -c "make install".
Podes saltarte esta sección se tes instalado CMake versión 2.4.5 ou superior.
Deberías poder usar directamente os binarios dispoñibles na páxina de CMake. Tamén tes paquetes específicos para distintas distribucións.
cs # 'cs' é unha función bash, prema aquí para saber máis 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
Primeiro imos ó directorio das fontes do usuario kde-devel (liña 1), descargamo-las fontes de CMake (liña 2) e descomprimímolas (liña 3). Creamos un directorio onde construir CMake (liña 4) e entramos nel (liña 5). Executamo-lo guión autosuficiente de CMake para configura-la súa construcción (liña 6), construímolo (liña 7) e instalámolo usando o usuario root (liña 8).
Se o teu sistema carece do comando sudo podes executar su -c "make install" no seu canto.
Next we need to get the Qt4 that is in KDE's source repository. KDE is guaranteed to build against any Qt 4.3. Qt 4.2 and earlier are not supported and will not work. You should use the copy in the KDE Subversion servers. (note: some distros, like Debian, tend to supply Qt with patches from KDE svn applied, so you may want to cheat and use precompiled Qt from your distro)
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 -nomake examples -nomake demos make -j2
# if we don't install, we'll just clear obj files to
# save disk space
if [ $QTDIR = `pwd` ]; then \
find . -name '*.o' -exec rm {} \; ; \
else make install; fi;
We switch back to the kde-devel user's home directory (line 1) and download the source code using subversion (svn) from KDE's repository (line 2). After changing into the resulting qt-copy directory (line 3), we run a script that manages the patches that come with qt-copy (line 4).
Once the patches have been applied, we then set up the build using the configure script (line 5-6). The various command line options used are explained in the qt-copy/README.qt-copy file. Finally, we build the minimal requirements for KDE (line 7) and install (line 10) Qt. If install dir is the same as the current dir (line 8), then we just free some space (line 9) instead. If you want all the example and demo applications, you can either build them individually or simply do a make from the qt-copy directory.
Note that the installation does not require root as it installs Qt locally into $QTDIR. Anyway, installation is only needed if $QTDIR differs from $HOME/qt-copy, which is not the case if you have exactly followed the instructions.
If you get "error: X11/Xlib.h: No such file or directory", install the devel package of xorg (the actual name may vary between operating systems, for example it is xorg-dev on Ubuntu based systems such as Kubuntu).
If you get an error in the configure step about missing defines, check the value of $QMAKESPEC. Some distributions set this to point directly to the system-installed Qt. If unset QMAKESPEC solves the problem, you probably want to add it to the ~/.bashrc script.
If you get an error ".pch/debug-shared/QtCore", this is because Qt-4.3 enables precompiled headers if your gcc supports it, but for some reason it doesn't work for you. If you use distcc, configure qt with -no-pch. If you use icecream, update to the latest icecream from svn trunk.
Try running any Qt program, like assistant. Note: You may need to run xhost +local:kde-devel as your regular kde3 user to run this application. If it crashes in QSpanData::adjustSpanMethods, then your problem is the oxygen style. Try removing lib/kde4/plugins/styles/kstyle-oxygen.so and lib/kde4/plugins/styles/oxygen.so if they exist in the KDE install prefix.
| Warning |
|---|
| If you have jumped to this section without reading Setting Up The Environment, the recipes provided will not work. The recipes are not in error; cs and cb are not typos. Your environment needs to be set up correctly for these instructions to work for you. |
There are several libraries that KDE applications rely on in the kdesupport module. This includes Strigi and Soprano for file metadata and search, 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.16; version 0.9.17 does not work), and either libxml2 or libexpat.
cs # cs is not a typo svn checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport/ cd kdesupport cmakekde
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 manualy into the kdesupport directory in ~ and execute the command cmakekde. if this still doesnt 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? 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-copy as describe above, or "sudo make install".
We can now move on to building KDE's base libraries.
cs # cs is not a typo mkdir KDE && cd KDE svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs cd kdelibs cmakekde
We change to the base source directory (line 1) then make and go into the KDE directory (line 2). We download the sources for kdelibs using subversion (line 3), go into the new ~/kde/src/KDE/kdelibs directory (line 4), and commence the build (line 5). This will leave us in the kdelibs build directory after the build is completed.
| Tip |
|---|
| There might be missing dependencies on your system! They are easily overlooked in the output of cmakekde. You might want to do a cmake $KDE_SRC/KDE/MODULE_NAME prior to compiling any kde modules (like kdelibs, kdepimlibs etc.) |
There are additional CMake modules in kdelibs/cmake/modules/ that are necessary for building KDE4 applications. These will be installed for you when kdelibs itself is installed.
If you have problems compiling kdelibs, first make sure the software in the Required Software section above is installed and works. Other possible hints include:
If cmakekde still gives the same error then try this
cd cmake -DCMAKE_INSTALL_PREFIX=$KDEDIR \ -DCMAKE_BUILD_TYPE=debugfull \ -DKDE4_BUILD_TESTS=ON \ ~/kde/src/KDE/kdelibs make make install
CMake Error: KDE Requires Qt to be built with SSL support
, install openssl-devel, and re-compile QT.
kdelibs/kimgio/ico.cpp:188: undefined reference to `QImage::jumpTable()' it means you compiled QT without QT3 support(no, linking to a true QT3 install won't work)
After kdelibs, but before kdebase, you need to build and install kdepimlibs.
cs KDE # cs is not a typo svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdepimlibs cd kdepimlibs cmakekde
We go into the KDE source directory (line 1), download the source code for kdepimlibs using subversion (line 2) and then go into the new ~/kde/src/KDE/kdepimlibs directory (line 3). We then commence the build (line 4). This will leave us in the kdepimlibs build directory after the build is completed.
If you have trouble compiling kdepimlibs:
You may need kdebase for some kioslaves.
cs KDE # cs is not a typo svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebase cd kdebase cmakekde
If you have troubles compiling kdebase:
Although the API documentation for KDE is available online at api.kde.org, it is sometimes useful to have it on your own disk, for example when you want to use KDevelop for browsing the documentation or when you are not able to be online all the time.
Be aware that generating the API documentation can take several hours and takes almost half a gigabyte of diskspace. The generation is handled by a script in kdelibs/doc/api, you need doxygen to be able to run it.
To build the API documentation for kdelibs, type the following:
cs KDE/kdelibs # cs is not a typo $KDE_SRC/KDE/kdelibs/doc/api/doxygen.sh \ --doxdatadir=$KDE_SRC/KDE/kdelibs/doc/common .
Repeat for other modules as desired.
cd <module home> $KDE_SRC/KDE/kdelibs/doc/api/doxygen.sh \ --doxdatadir=$KDE_SRC/KDE/kdelibs/doc/common .
Another, even easier method involves downloading this Doxyfile to your local system. Then simply change directory to where you want to create the documentation and run
% doxygen /path/to/Doxyfile
Then review the file doxygen.log to see the doxygen errors and warnings. You'll find the actual documentation in the apidocs subdirectory.
In order to keep the kde4 installation up to date, each of the modules installed should be updated periodically. As Monday is the day for big changes in kdelibs, Tuesday may be the best day to do this. For each module checked out, run svn up and make.
For example:
cs kdesupport # cs is not a typo
svn up
cb # cb is not a typo
make -j2 VERBOSE=1 && make install
What can happen over time, after some svn up commands, is that some of the tools used in the KDE build chain change their output format. For example, kcfg files are read by kconfig_compiler to produce configuration dialogs. CMake cannot detect those changes, and the compilation might fail. A workaround is to always force a re-generation of all such files:
find $KDE_SRC/KDE/kdebase -name "*.kcfg" | xargs touch
The same applies to ui files as produced by Qt designer.
You are now ready to start building other svn modules in the same fashion as you built kdebase, running and testing KDE4 or writing your own patches and applications.
See the Set up KDE 4 for development tutorial for how to start KDE 4 applications and how to use KDevelop to work on them.