Detailed instructions on building KDE 4 in Gentoo via portage can be found in the [http://overlays.gentoo.org/proj/kde/wiki KDE overlay wiki]. They are discussed in the thread [http://forums.gentoo.org/viewtopic-t-530111-postdays-0-postorder-asc-start-0.html KDE 4 monolithic ebuilds].

Instead of using the commands above, you can also use the User module in the KDE Control Center if you already have KDE3 installed.

+

No canto de usar os comandos de riba, pode usar o módulo de usuario do Centro de Control de KDE, se xa ten instalado KDE 3.

−

=== Setting up the environment ===

+

=== Configurar o contorno ===

−

Copy the {{path|~/.bashrc}} from your normal user account to the new kde-devel account. Next, copy and paste the contents of the [[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|example .bashrc]] into {{path|~kde-devel/.bashrc}}. Be sure to comment out the line <tt>alias make=makeobj</tt> if you do not have the <tt>[[Getting Started/Build/KDE4#Required Software|makeobj]]</tt> command available. You will probably also want to modify the path to make sure it doesn't include your kde3 paths. To make it run, you have to open a new bash or to execute

On some systems a new user is configured by default to use {{path|/bin/sh}}. If this is not the case on your system, you can skip this section. Using {{path|/bin/sh}} can be very inconvenient to work with and you may want to change it to {{path|/bin/bash}} or another shell.

Another option is to use the <tt>vipw</tt> application as root to safely edit your {{path|/etc/passwd}}. Locate 'kde-devel' in the the file. Change '{{path|/bin/sh}}' at the end of the line to read '{{path|/bin/bash}}', save your changes and exit.

QtDBus and KDE are known to work with D-Bus versions 0.62, as well as 0.92 and upwards. Versions 0.60 and 0.61 may work too but are not tested. Versions 0.90 and 0.91 are known not to work. We recommend using post-1.0 release versions (at least 0.94), so consider upgrading if you haven't done so.

{{tip|Make sure you did set up your environment correctly as described [[Getting_Started/Build/KDE4#Setting_up_the_environment|above]]. This is necessary for the <tt>cs</tt> and <tt>cb</tt> functions to work.}}

After changing into the source directory (line 1), D-Bus source code is downloaded from freedesktop.org (line 2) and unpacked (line 3). After going into the newly created D-Bus directory (line 4), the build is set up using the supplied {{path|configure}} script (line 5). After building (line 6) and installing (line 7) D-Bus, we use the <tt>dbus-uuidgen</tt> tool to install a machine identification file that allows the bus to start automatically when the desktop session starts (line 8).

First, we go back to the <tt>kde-devel</tt> user's source directory (line 1), get the CMake sources (line 2) and unpack them (line 3). We create a directory to build CMake in (line 4) and go into it (line 5). We then run the CMake bootstrap script to set up the CMake build (line 6), then make (line 7) and install it (line 8) using the root user.

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)

We switch back to the <tt>kde-devel</tt> 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 {{path|qt-copy}} directory (line 3), we run a script that manages the patches that come with <tt>qt-copy</tt> (line 4).

Once the patches have been applied, we then set up the build using the <tt>configure</tt> script (line 5-6). The various command line options used are explained in the {{path|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 <tt>make</tt> from the {{path|qt-copy}} directory.

Note that the installation does not require root as it installs Qt locally into {{path|$QTDIR}}. Anyway, installation is only needed if {{path|$QTDIR}} differs from {{path|$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 <tt>xorg</tt> (the actual name may vary between operating systems, for example it is <tt>xorg-dev</tt> on Ubuntu based systems such as Kubuntu).

If you get an error in the configure step about missing defines, check the value of <tt>$QMAKESPEC</tt>. Some distributions set this to point directly to the system-installed Qt. If <tt>unset QMAKESPEC</tt> solves the problem, you probably want to add it to the <tt>~/.bashrc</tt> 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 {{program|assistant}}. '''Note:''' You may need to run <tt>xhost +local:kde-devel</tt> as your regular kde3 user to run this application. If it crashes in QSpanData::adjustSpanMethods, then your problem is the oxygen style. Try removing {{path|lib/kde4/plugins/styles/kstyle-oxygen.so}} and {{path|lib/kde4/plugins/styles/oxygen.so}} if they exist in the KDE install prefix.

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 # [[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts/.bashrc|cs is not a typo]]

+

svn checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport/

svn checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport/

cd kdesupport

cd kdesupport

cmakekde

cmakekde

−

=== What's Happening ===

+

=== Que acontece? ===

−

We change to the base source directory (line 1). We download the sources in kdesupport using subversion (line 2), go into the new {{path|~/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.

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 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 {{path|~/kde/src/KDE/kdelibs}} directory (line 4), and commence the build (line 5). This will leave us in the <tt>kdelibs</tt> build directory after the build is completed.

If you have problems compiling kdelibs, first make sure the software in the [[Getting_Started/Build/KDE4#Required_Software|Required Software]] section above is installed and works. Other possible hints include:

* If you received an error stating "Please create a separate build directory and run 'cmake path_to_kdelibs [options]' there.", then you need to change to your build directory before running cmakekde. (e.g <tt>cs KDE/kdelibs && cb && cmakekde</tt>) If the message stays, run 'svn status' in the kdelibs directory and remove all files labeled with '?'.

* Qt-4.3 upgrade: if you get a link error in kjsembed talking about QScriptEngine, edit CMakeCache.txt in kdelibs and remove the lines that talk about QT_QTUITOOLS_LIBRARY, then type make again (that static library has a new dependency, and the cmake code that adds it needs to run).

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 {{path|~/kde/src/KDE/kdepimlibs}} directory (line 3). We then commence the build (line 4). This will leave us in the <tt>kdepimlibs</tt> build directory after the build is completed.

* the cmakekde command may require a later version of the gpgme library. This is available from the project's web site: http://www.gnupg.org/(en)/download/index.html - please note that the build of gpgme also requires libgpg-error, also available from the same location. Both libraries are installed by the "./configure", "make" and "sudo make install" sequence, with the gpgme library configured with the additional "--with-gpg-error-prefix" parameter. You may need to overwrite your existing "/usr/bin/gpgme-config" file with the newer version for the kdepimlibs to pick up the new install.

* if you get an error saying "Please set the following variables: X11_XTest_LIB (ADVANCED)", install the devel package of <tt>Xtst</tt>. On some systems, this is packaged separately from <tt>xext</tt> and called <tt>x11proto-xext-dev</tt> or <tt>libxtst-dev</tt>. You may also need to remove the CMakeCache.txt file in the build dir after installing the package.

* if you get the error "CMake Error: This project requires some variables to be set, and cmake can not find them. Please set the following variables: KMETADATA_LIBRARIES", you need to install soprano from kdesupport and to rebuild kdelibs

+

* se obté-lo erro "CMake Error: This project requires some variables to be set, and cmake can not find them. Please set the following variables: KMETADATA_LIBRARIES", precisas instalar soprano, de kdesupport, e reconstruír kdelibs.

−

* if you get the error "‘XserverRegion’ does not name a type" make sure you have libxcomposite headers installed (<tt>libxcomposite-dev</tt> in ubuntu)

+

* se obté-lo erro "‘XserverRegion’ does not name a type" asegúrate de ter as cabeceiras de libxcompolite instaladas (<tt>libxcomposite-dev</tt> en ubuntu).

−

== Generating local API documentation ==

+

== Xerar documentación local da API ==

−

Although the API documentation for KDE is available online at [http://api.kde.org api.kde.org], it is sometimes useful to have it on your own disk, for example when you want to use [[Getting_Started/Set_up_KDE_4_for_development#KDevelop|KDevelop]] for browsing the documentation or when you are not able to be online all the time.

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 <tt>svn up</tt> and <tt>make</tt>.

What can happen over time, after some <tt>svn up</tt> commands, is that some of the tools used in the KDE build chain change their output format. For example, <tt>kcfg</tt> files are read by <tt>kconfig_compiler</tt> 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:

se obté-lo erro "CMake Error: This project requires some variables to be set, and cmake can not find them. Please set the following variables: KMETADATA_LIBRARIES", precisas instalar soprano, de kdesupport, e reconstruír kdelibs.

se obté-lo erro "‘XserverRegion’ does not name a type" asegúrate de ter as cabeceiras de libxcompolite instaladas (libxcomposite-dev en ubuntu).