Be sure you followed the steps in the KDE 4 [[Getting_Started/Build/KDE4|build instructions]] and have a working KDE 4 environment. Make sure simple KDE 4 applications like ''Konsole'' or ''KWrite'' can be started from the command line of the ''kde-devel'' user without problems.

Be sure you followed the steps in the KDE 4 [[Getting_Started/Build/KDE4|build instructions]] and have a working KDE 4 environment. Make sure simple KDE 4 applications like ''Konsole'' or ''KWrite'' can be started from the command line of the ''kde-devel'' user without problems.

−

The following steps are all done with the ''kde-devel'' user. You need to login as that user by typing <code bash>su - kde-devel</code>.

+

The following steps are all done with the ''kde-devel'' user. You need to login as that user by typing <syntaxhighlight lang="bash">su - kde-devel</code>.

==== Setting up the environment ====

==== Setting up the environment ====

KDevelop has no native support for CMake projects. Fortunately, CMake has the ability to generate KDevelop project files itself. In order to do this, you need to pass the ''-GKDevelop3'' flag to the ''cmake'' command. This tells CMake to generate project files for KDevelop alongside the normal makefiles. The best way to do this is to modify your ''cmakekde'' function in your [[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts/.bashrc|{{path|.bashrc}}]]. Just change

KDevelop has no native support for CMake projects. Fortunately, CMake has the ability to generate KDevelop project files itself. In order to do this, you need to pass the ''-GKDevelop3'' flag to the ''cmake'' command. This tells CMake to generate project files for KDevelop alongside the normal makefiles. The best way to do this is to modify your ''cmakekde'' function in your [[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts/.bashrc|{{path|.bashrc}}]]. Just change

−

<code bash>

+

<syntaxhighlight lang="bash">

cmake $srcFolder -DCMAKE_INSTALL_PREFIX=$KDEDIR \

cmake $srcFolder -DCMAKE_INSTALL_PREFIX=$KDEDIR \

-DCMAKE_BUILD_TYPE=debugfull&& \

-DCMAKE_BUILD_TYPE=debugfull&& \

Line 291:

Line 291:

</code>

</code>

to

to

−

<code bash>

+

<syntaxhighlight lang="bash">

cmake $srcFolder -GKDevelop3 -DCMAKE_INSTALL_PREFIX=$KDEDIR \

cmake $srcFolder -GKDevelop3 -DCMAKE_INSTALL_PREFIX=$KDEDIR \

-DCMAKE_BUILD_TYPE=debugfull&& \

-DCMAKE_BUILD_TYPE=debugfull&& \

Line 303:

Line 303:

A simple way to do this is to add the following function to your {{path|.bashrc}}:

A simple way to do this is to add the following function to your {{path|.bashrc}}:

−

<code bash>

+

<syntaxhighlight lang="bash">

function start3app {

function start3app {

mkdir -p /tmp/$USER-kde

mkdir -p /tmp/$USER-kde

Line 319:

Line 319:

</code>

</code>

−

The ''PATH'' and ''LD_LIBRARY_PATH'' variables are taken from the KDE 3 user, and they may be different on your system. Type <code bash>echo $PATH</code> and <code bash>echo $LD_LIBRARY_PATH</code> as normal KDE 3 user to get these values. The above function assumes that KDE 3 is installed in the {{path|/usr}} prefix, as it is the case on Debian-based systems. If your KDE 3 is installed to a different prefix, you need to change the line setting ''KDEDIR'' accordingly. Here's an example how you find out your KDE installation prefix; in this example it is /opt/kde3:

+

The ''PATH'' and ''LD_LIBRARY_PATH'' variables are taken from the KDE 3 user, and they may be different on your system. Type <syntaxhighlight lang="bash">echo $PATH</code> and <syntaxhighlight lang="bash">echo $LD_LIBRARY_PATH</code> as normal KDE 3 user to get these values. The above function assumes that KDE 3 is installed in the {{path|/usr}} prefix, as it is the case on Debian-based systems. If your KDE 3 is installed to a different prefix, you need to change the line setting ''KDEDIR'' accordingly. Here's an example how you find out your KDE installation prefix; in this example it is /opt/kde3:

sux - kde-devel</code>
El {{path|[[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts/.bashrc|.bashrc]]}} debería configurar correctamente las variables de entorno y todo lo demás. Para iniciar una aplicación, simplemente escribe su nombre; por ejemplo <syntaxhighlight lang="bash">kwrite</code>{{Note (es)|
Si aparecen errores acerca de tipos mime inexistentes o algo parecido, intenta lo siguiente:
* ejecutar <syntaxhighlight lang="bash">unset XDG_DATA_DIRS ; kbuildsycoca4</code>}}
==== Usar la consola normal sin sux ====
El método más sencillo para lanzar aplicaciones de KDE 4 es usar <tt>su</tt> para iniciar sesion como el usuario <tt>kde-devel</tt> y después simplemente inicia cualquier aplicación de KDE 4 desde la línea de comandos. Para iniciar sesión, escribe
<syntaxhighlight lang="bash">su - kde-devel</code>
y después, trás introducir la contraseña
<syntaxhighlight lang="bash">exportDISPLAY=:0</code>{{Note (es)|Exportar la variable <tt>DISPLAY</tt> es necesario para que las aplicaciones de KDE 4 aparezcan en el escritorio normal de KDE 3.}}
El {{path|[[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts/.bashrc|.bashrc]]}} debería configurar correctamente las variables de entorno y todo lo demás. Para iniciar una aplicación, simplemente escribe su nombre; por ejemplo <syntaxhighlight lang="bash">kwrite</code>{{Note (es)|
Si aparecen errores acerca de tipos mime inexistentes o algo parecido, intenta lo siguiente:
* ejecutar <syntaxhighlight lang="bash">unset XDG_DATA_DIRS ; kbuildsycoca4</code>}}{{Note (es)|
Si aparece un error indicando que no es posible conectar con un servidor X, ejecuta
<syntaxhighlight lang="bash">sudoxhost +local:kde-devel</code>
como el usuario normal de KDE 3 para asegurarte de que la aplicación se puede conectar a la sesión X actual.
Aunque el servidor X debería aceptar conexiones TCP entrantes, las distribuciones suelen desactivado por defecto (como en Kubuntu Feisty). Si usas <tt>kdm</tt> debes editar <tt>/etc/kde3/kdm/kdmrc</tt> como root y asegurarte de que no contenga:
<code>ServerArgsLocal=-nolisten tcp</code>
Una vez que hayas corregido esto, necesitarás reiniciar el servidor X. El comando <tt>xhost</tt> ya no debería devolver el error "unable to open display".
Por comodidad, deberías poner esto en el Autostart del usuario habitual. Para ello, crea un nuevo archivo en el directorio <tt>$HOME/.kde/Autostart</tt> del usuario normal con el siguiente contenido:
<syntaxhighlight lang="bash">#! /bin/shxhost +local:kde-devel
</code>
Asegúrate de que el nuevo archivo es ejecutable usando <tt>chmod +x</tt> sobre él.
Si quieres saber más acerca de los '''problemas de seguridad''' que implica el uso de <tt>xhost</tt>, consulta [http://bau2.uibk.ac.at/matic/xsecur.htm este artículo]}}
==== Usar SSH ====
La manera más simple de ejecutar una aplicación de KDE con SSH en tu entorno de escritorio actual es tener una sesión X-aware en la consola como usuario <tt>kde-devel</tt>así:
<syntaxhighlight lang="bash">ssh-X kde-devel@localhost</code>
Ahora puedes ejecutar aplicaciones de KDE como normalmente lo harías, por ejemplo:
<syntaxhighlight lang="bash">kwrite</code>
Las dos lineas pueden ser combinadas:
<syntaxhighlight lang="bash">ssh-X kde-devel@localhost kwrite</code>{{Note (es)|
Si esto te da algún error, intenta con los consejos de la parte superior.
}}
===== Iniciar sesión sin contraseña =====
Antes de que podamos hacer algo serio con este método, es necesario crear una sesión sin contraseña. Para empezar, ejecuta el siguiente comando como el usuario regular de tu escritorio:
<syntaxhighlight lang="bash">ssh-keygen-t rsa</code>
Presiona ENTER trés veces para aceptar la ruta {{path|~/.ssh/id_rsa}} y la clave vacía. Ahora, copia la única linea en{{path|~/.ssh/id_rsa.pub}} que aparece después de ejecutar este comando:<syntaxhighlight lang="bash">cat ~/.ssh/id_rsa.pub</code>
Después de copiar esa linea, regresa dentro del usuario <tt>kde-devel</tt>
y pon la linea copiada en el archivo {{path|$HOME/.ssh/authorized_keys}}:
ssh-X kde-devel@localhost $HOME/kde/bin/kwrite \
$HOME/.ssh/authorized_keys
Pega la linea, guarda el archivo y cierra KWrite. Ahora, intenta ejecutar KWrite otra vez con el mismo comando SSH; no deberías de necesitar introducir una contraseña desde ahora:
<syntaxhighlight lang="bash">ssh-X kde-devel@localhost $HOME/kde/bin/kwrite</code>{{Warning (es)|Usando una sesión SSH sin contraseña tiene muchos "riesgos de seguridad", así que asegurate de proteger tu archivo <tt>~/.ssh/id_rsa</tt> restringiendo el acceso con <syntaxhighlight lang="bash">chmod og-xrw ~/.ssh/id_rsa</code>(although the file should have these permissions when it is created)}}
===== El archivo .desktop de SSH =====
Si quieres ser capaz de ejecutar aplicaciones más fácilmente que ejecutarlas con un comando SSH desde la consola, una manera de hacerlo es crear archivos <tt>.desktop</tt> que <tt>ssh</tt> dentro de la otra sesión.
{{Note (es)|Esto será útil únicamente si tu escritorio soporta archivos .desktop, pero por lo menos KDE y GNOME lo hacen.}}
Puedes iniciar con un archivo .desktop existente como una plantilla (como alguno que esté en tu escritorio o puedes crear uno desde el inicio. La idea principal es establecer la ruta de la consola con este comando:
<syntaxhighlight lang="bash">ssh-X kde-devel@localhost $HOME/kde/bin/</code>
Un archivo .desktop normal que ejecuta KWrite tendría el siguiente contenido:
<syntaxhighlight lang="ini">[Desktop Entry]Categories=Qt;KDE;TextEditor;
Comment=
DocPath=kwrite/index.html
Encoding=UTF-8Exec=ssh-X kde-devel@localhost /home/kde-devel/kde/bin/kwrite %U
GenericName=Text Editor
Icon=kwrite
InitialPreference=8MimeType=text/plain
Name=KWrite (kde-devel)Path=
StartupNotify=falseTerminal=falseTerminalOptions=
Type=Application
X-DBUS-StartupType=Multi
X-DCOP-ServiceType=non
X-KDE-StartupNotify=true
X-KDE-SubstituteUID=false
X-KDE-Username=
</code>{{Tip| Las aplicaciones ejecutadas usando SSH de esta manera no realizan las respuestas correctas de lanzamiento, por lo que probablemente querrás deshabilitar el registro de lanzamiento de tus archivos .desktop}}{{Note (es)|Para crear correctamente un archivo .desktop para una aplicación de KDE 4 usando este método, el paquete de la aplicación tiene que haber sido instalado dentro del directorio <tt>~/kde/bin</tt> usando el comando <tt>cmakekde</tt>}}
=== Lanzando sesiones de KDE 4 ===
==== Anidando una sesión de KDE 4 ====
{|align="right"|[[image:Snapshot1.png|right|thumb|200px|Nested]]|}
En lugar de usar una nueva X virtual para desarrollar software, puedes usar Xephyr para anidar tu sesión de KDE 4 dentro de tu KDE 3 actual u otro entorno X11.
Puedes hacer esto también con xnest, pero como xnest no maneja extenciones como Render, mucha gente prefiere Xephyr.
Si quieres tener una sesión mínima de KDE funcionando, simplemente lanza Xephyr (disponible en Kubuntu como xserver-xephyr; los usuarios de Gentoo sólo compilen x11-base/xorg-server con USE="kdrive"):
Xephyr :1-extension GLX &
Ahora puedes lanzar KDE:
exportDISPLAY=:1/path/to/kde4/bin/startkde-modified &
startkde-modified es una copia de startkde-script que incluye las siguientes lineas en la parte de arriba:
<syntaxhighlight lang="bash">exportKDEDIR=`kde4-config --prefix`exportLD_LIBRARY_PATH=$KDEDIR/lib
exportPATH=$KDEDIR/bin/:$PATHexportKDEHOME=~/.kde4
</code>
Puedes usar Xephyr con KDM mediante el protocolo Xdmcp y simplemente una nueva sesión de KDE 4 para KDM.
En Kubuntu, lo puedes habilitar cambiando:
<syntaxhighlight lang="ini">[Xdmcp]# Whether KDM should listen to incoming XDMCP requests.# Default is trueEnable=false</code>
en {{path|/etc/kde3/kdm/kdmrc}} a:
<syntaxhighlight lang="ini">[Xdmcp]# Whether KDM should listen to incoming XDMCP requests.# Default is trueEnable=true</code>
y ajustar tu {{path|/etc/kde3/kdm/Xaccess}} para permitir el acceso a tu máquina local.
Adicionalmente deberías segurarte de configurar directivas de bloqueo de puerto en toda las interfaces externas para el puerto Xdmcp si esto lo estás haciendo en una laptop o una PC en un entorno poco confiable.
Si haces esto, simplemente lanza Xephyr:
Xephyr -query localhost :1-host-cursor-screen 1024x768&
Donde <tt>-host-cursor</tt> trata de reusar el cursor principal y <tt>-screen</tt> establece las dimenciones de pantalla.
Nota: Si obtienes muchos errores de rechazo de conexión, podrías querer usar la opción -ac de Xephyr. Por ejemplo:
Xephyr -ac :1&
Otra opción a tratar si obtienes muchos errores de rechazo de conexión es que tal vez necesites acceso a tu usuario kde-devel para X server. Como root o usando sudo ejecuta:
xhost +local:kde-devel
Si no tienes Xephyr, puedes usar también Xnest:
Xnest -ac :1&exportDISPLAY=:1<BR>-----{{improve}}[[User:Sping|Sping]] 00:25, 9 April 2007(CEST)<BR>
Yo use este para mi script de inicio "nested_kde4.sh":
#! /bin/bashNESTED_KDE_DISPLAY_BACKUP=$DISPLAYexportDISPLAY=:0
Xephyr :1-screen 1024x768 &exportDISPLAY=:1$HOME/kde/bin/startkde-modified &exportDISPLAY=${NESTED_KDE_DISPLAY_BACKUP}
Si obtienes:
"Call to lnusertemp failed (temporary directories full?).
Check your installation."
Intenta esto:
mkdir/var/tmp/kde-devel-kde4
Este código asume que trabajas con el usuario "kde-devel".
{{Note|En la mayoría de los casos necestas reemplazar "startkde-modified" con "startkde"}}-----
==== Solitary KDE 4 session ====
{|align="right"|[[image:solitary.png|right|thumb|200px|Solitary]]|}
To run a full KDE 4 desktop environment session, you can either start it from the command line as you normally would, with something like this:
X :1&exportDISPLAY=:1
startkde
{{Note|If the X server refuses the connection saying something like: <tt>Xlib: connection to ":1.0" refused by server</tt>, try <tt>X -ac :1</tt> instead.}}
or you can can add it to your login manager. If you are using KDM (or a compatible login manager) this is done by creating a .desktop filein either {{path|`kde-config --prefix`/share/apps/kdm/sessions/}} or in{{path|/usr/share/xsessions/}}. The easiest thing to do is to copy an existing {{path|kde.desktop}}file and name it {{path|kde4.desktop}}. Open this new .desktop filein a text editor and change the <tt>Exec</tt>, <tt>TryExec</tt> and <tt>Name</tt> entries to look something like this:
<syntaxhighlight lang="ini">Exec=$HOME/kde/bin/startkde
TryExec=$HOME/kde/bin/startkde
Name=KDE4
</code>
Replace {{path|$HOME/kde}}in the example above with the prefix you are installing KDE4 into.
After restarting the login manager (<tt>Alt+e</tt>in KDM) this new entry should appear in the sessions menu.
{{Note|You should have path to 'qdbus' program (usually it is $QTDIR/bin)in your $PATH to login successfully. If it is not there, you'll get an error message "Could not start DBus. Check your installation."}}
== Development tasks ==
=== KDevelop ===
This section will explain how to use KDevelop 3.4 to develop KDE 4 applications. If you have any questions, corrections or rants about this section, please post them on the discussion page.
==== Prerequisites ====
You need at least KDevelop 3.4 for this, which is still a KDE 3 application. Versions lower than 3.4 do not have Qt 4 support among other things. The KDE 4 version of KDevelop is not yet ready for serious development. You can get KDevelop at the [http://www.kdevelop.org/index.html?filename=3.4/download.html KDevelop homepage]. Make sure you install KDevelop like all other KDE 3 applications, '''not''' with your ''kde-devel'' user.
You also need the lastest ''GDB'' version, which is currently 6.6.0.
You need to have the kdelibs API documentation locally, which is described in the [[Getting_Started/Build/KDE4#Generating_local_API_documentation|build instructions]].
You also need ''ctags'', ''htdig'', ''htmerge'' and ''htsearch''. ''valgrind'' and ''callgrind'' can also be useful.
Be sure you followed the steps in the KDE 4 [[Getting_Started/Build/KDE4|build instructions]] and have a working KDE 4 environment. Make sure simple KDE 4 applications like ''Konsole'' or ''KWrite'' can be started from the command line of the ''kde-devel'' user without problems.
The following steps are all done with the ''kde-devel'' user. You need to login as that user by typing <syntaxhighlight lang="bash">su - kde-devel</code>.
==== Setting up the environment ====
KDevelop has no native support for CMake projects. Fortunately, CMake has the ability to generate KDevelop project files itself. In order to do this, you need to pass the ''-GKDevelop3'' flag to the ''cmake'' command. This tells CMake to generate project files for KDevelop alongside the normal makefiles. The best way to do this is to modify your ''cmakekde'' function in your [[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts/.bashrc|{{path|.bashrc}}]]. Just change
<syntaxhighlight lang="bash">
cmake $srcFolder -DCMAKE_INSTALL_PREFIX=$KDEDIR \
-DCMAKE_BUILD_TYPE=debugfull&& \
make && \
make install;
</code>
to
<syntaxhighlight lang="bash">
cmake $srcFolder -GKDevelop3 -DCMAKE_INSTALL_PREFIX=$KDEDIR \
-DCMAKE_BUILD_TYPE=debugfull&& \
make && \
make install;
</code>
After you have done that, re-login so that the changes to the {{path|.bashrc}} file take effect. Then you need to rerun ''cmakekde'' in the (root) build directory of the project you want to work on with KDevelop (if you didn't use ''-GKDevelop3'' on the [[Getting_Started/Build/KDE4#Setting_up_the_environment|building step]]). For example, if you want to work on Konsole, which lives in ''kdebase'', you need to run cmakekde in the {{path|$KDE_BUILD/KDE/kdebase}} directory. This unfortunately completely rebuilds everything, but only once when you change the generator.
Since all environment variables of the kde-devel user are KDE 4 specific, these need to be set back to match your KDE 3 environment before starting KDevelop.
A simple way to do this is to add the following function to your {{path|.bashrc}}:
<syntaxhighlight lang="bash">function start3app {mkdir-p/tmp/$USER-kde
exportPATH=/opt/kde3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
exportLD_LIBRARY_PATH=
exportKDETMP=/tmp/$USER-kde
exportKDEVARTMP=/var/tmp/$USER-kde
exportKDEHOME=$HOME/.kde
exportKDEDIR=/usr
exportKDEDIRS=$KDEDIRexportDISPLAY=:0eval"$@"source$HOME/.bashrc #Reset environment variables again}</code>
The ''PATH'' and ''LD_LIBRARY_PATH'' variables are taken from the KDE 3 user, and they may be different on your system. Type <syntaxhighlight lang="bash">echo$PATH</code> and <syntaxhighlight lang="bash">echo$LD_LIBRARY_PATH</code>as normal KDE 3 user to get these values. The above function assumes that KDE 3 is installed in the {{path|/usr}} prefix, as it is the case on Debian-based systems. If your KDE 3 is installed to a different prefix, you need to change the line setting ''KDEDIR'' accordingly. Here's an example how you find out your KDE installation prefix; in this example it is /opt/kde3:
<syntaxhighlight lang="bash">
kde-config --prefix
/opt/kde3
</code>
Now you should be able to start KDevelop by typing <tt>start3app kdevelop</tt>. Do that now.
{{tip|
You can start any KDE 3 application with the <tt>start3app</tt> function. Useful candidates include ''Kompare'' and ''kdesvn''.
However, you can not start ''KDbg'' this way to debug KDE 4 applications, since then the environment variables for the debugged application are wrong.
}}
<!--
{{tip|
Instead of starting KDevelop by using the ''start3app'' script as ''kde-devel'' user, you can also use the KDE run dialog ''(Alt+F2)'' to start KDevelop:
[[Image:Minicli.png]]
This starts KDevelop as ''kde-devel'' user but uses the environment variables of the normal user, just like the ''start3app'' script does.
}}
-->
===== TroubleShooting =====
'''Symptome:''' kdevelop says "cannot talk to klauncher". You cannot open a file.
'''Solution:''' add your KDE library path to LD_LIBRARY_PATH, e.g.:
export LD_LIBRARY_PATH=/opt/kde3/lib
==== Setting up KDevelop ====
Now that KDevelop has started, you need to adjust a few settings. Go to ''Settings->Configure KDevelop...->Documentation'' for this. Remove all entries that are not relevant to KDE 4 coding.
{{note|Although environment variables like $HOME are used in this section, you should replace them with real paths because KDevelop does not resolve environment variables.}}
Optionally, you can add the kdelibs API documentation. You must [[Getting_Started/Build/KDE4#Generating_local_API_documentation|create it before]]. Then add the documentation by clicking ''Add...''. In this dialog, use the following settings:
* ''Type'': Doxygen Documentation Collection (needs to be set first)
* ''Location'': {{path|$KDE_SRC/KDE/kdelibs/kdelibs-apidocs/index.html}}
Now add the Qt API documentation, using the following settings:
* ''Type'': Qt Documentation Collection (needs to be set first)
* ''Location'': {{path|$HOME/qt-copy/doc/html/qt.dcf}}
After you have added kdelibs and Qt API documentation, make sure all checkboxes (''TOC'',''Index'' and ''Search'') are enabled. Then, go to the ''Full Text Search'' tab and make sure the paths to the ''htdig'', ''htmerge'' and ''htsearch'' executables are correct. You can then close the settings dialog.
Now it is time to open the project you want to work on by clicking ''Project->Open Project...''. The project files are located in the build directory. For example, if you want to work on Konsole, you need to open {{path|$KDE_BUILD/KDE/kdebase/apps/konsole/konsole.kdevelop}}. You now need to adjust a few project-specific settings in ''Project->Project Options''. You need to do this every time you start to work on a different project.
{{note|
Sometimes, a KDevelop project file is not present for the folder you want to work on.
This can have several reasons, it depends on how the CMake files are written. Usually, CMake files which have a <tt>project(projectname)</tt> statement in them should work fine. Once you are familiar enough with CMake, you can try adding the statement.
A workaround for this is to simply use the KDevelop project file of the parent folder, or even higher. In this case, you need to use the <tt>Make Active Directory</tt> entry in the context menu of the <tt>File Selector</tt> sidetab. With this, you can ignore the other unwanted folders when building and installing.
}}
* ''C++ Support->Code Completion''
:Here you need to add code completion databases for Qt and kdelibs, and more if you like, for example you might need a database for ''kdepimlibs'' when working on ''kdepim''.
:For kdelibs, click the ''Add...'' button and choose ''KDevelop Custom Directory PCS Importer'', then add your KDE include directory ({{path|$HOME/kde/include}}) to the list and proceed. You can use the file selection dialog and the ''Add'' button to add it.
:Now, add the database for Qt 4 by selecting ''KDevelop Qt4 PCS Importer'' this time. You need to select the Qt 4 include directory, which is {{path|$HOME/qt-copy/include}}.
{{note|The Qt4 PCS Importer is only needed if you didn't install Qt4, i.e. you use it directly from the build directory. The drawback of using the Qt4 importer is that it doesn't show progress and the application seems to hang while it imports. The alternative is to use the Custom Directory PCS Importer for this too}}
* ''C++ Support->Qt Options''
:Check ''Enable Qt options'' and choose Qt4 as your version. Set the ''QMake Binary'' path to {{path|$HOME/qt-copy/bin/qmake}}. Then choose ''Qt 4 style'' as ''Qt include syntax''. Use {{path|$HOME/qt-copy/bin/designer}} as ''Designer Binary''. Make sure to use the ''Change Plugin Paths'' dialog to add the plugin directory from KDE so you see the KDE widgets when designer is started. To do this add {{path|$HOME/kde/lib/kde4/plugins}} to the lineedit and then click the ''Add'' button.
* ''Run Options''
:Make sure you use the correct binary as ''Executable''. For example, if you want to run Konsole, this is {{path|$KDE_BUILD/KDE/kdebase/apps/konsole/src/konsole}}. You should add ''--nofork'' to the ''Debug Arguments'' or debugging some applications like ''KMail'' will not work at all.
:Because the ''start3app'' functions changes some environment variables, you need to change them back here so the KDE 4 applications can be run without problems from within KDevelop.
:For some applications, like Konsole, this is not strictly necessary, but others like KMail will crash if you do not change this.
:Simply click the ''Add / Copy'' button to add new environment variables. You will need the following, which are the same as in your [[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts/.bashrc|{{path|.bashrc}}]]:
:{| border="1"
|-
! Name
! Value
|-
| KDEHOME
| $HOME/.kde4
|-
| PATH
| $KDEDIR/bin:$QTDIR/bin:/usr/local/bin:$PATH
|-
| LD_LIBRARY_PATH
| $KDEDIR/lib:$QTDIR/lib:$LD_LIBRARY_PATH
|-
| KDETMP
| /tmp/$USER-kde4
|-
| KDEVARTMP
| /var/tmp/$USER-kde4
|-
| KDEDIR
| $HOME/kde
|-
| KDEDIRS
| $KDEDIR
|-
| LD_BIND_NOW
| 42
|}
* ''Build Options->Build''
:Make sure the correct build directory is selected. Again, for Konsole, this would be {{path|$KDE_BUILD/KDE/kdebase/apps/konsole}}.
* ''Build Options->Make''
:You might want to check ''Abort on first error''. You also might want to add ''VERBOSE='' or ''VERBOSE=1'' to ''Additional make options'' to control the level of verbosity for the build process.
:If you have more than one processor or if you have access to an icecream cluster, you might want to check the ''Run multiple jobs'' option and set the ''Number of simultaneous jobs'' to the number of available processors. This increases the compile speed. It is the same as the <tt>-j</tt> option for ''make''.
* ''Formatting''
:You should set all options here to match the coding style of the project you are working on.
* ''CTags->General''
:You need to correctly set the ''Path to ctags binary'', which is {{path|/usr/bin/ctags}} on Debian-based systems.
:You probably want to enable the <tt>When more than one hit, go directly to the first</tt> option.
Now you have finished adjusting your project-specific settings. Now you should remove some plugins you do not need, in ''Settings->Configure Plugins...''. I for example disable the following plugins:
<small>Abbreviation Expansion, Code Snippets, Doxygen Support, Embedded Konsole, File Tree, '''Final Packaging Support''', "Open with" Menu Addon, QuickOpen, Regular Expression Tester, Scripting, '''Security Checker''', Shell Filtering and Insertion, Text Structure and Tools Menu Addition.</small>
You should at least disable the bold ones.
Now, open any source file if none is open already. This will enable the ''Settings->Configure Editor...'' entry, where you need to set the tab options to match the tab style used by the project you are working on. The important settings are:
* ''Appearance->Borders->Show line numbers'': Should be checked.
* ''Appearance->Borders->Show icon border'': Should be checked.
* ''Editing->Tabulators''
* ''Editing->Static Word Wrap->Show marker'': Should be checked
* ''Indentation->Automatic Indentation->Indentation mode'': Should be ''C Style''
* ''Indentation'' in general
In the mainwindow, click the ''CTags'' tab on the bottom tabbar, then click the ''Regenerate'' button to create a CTags database for easier source code navigation.
Now you have completed all essential configuration, congratulations!
==== Using KDevelop ====
Refer to the [http://docs.kde.org/development/en/kdevelop/kdevelop/ KDevelop manual] for general help using KDevelop. The following section will only deal with special cases for KDE 4.
===== Debugging =====
KDE apps have many symbols, which means that you need a lot of memory to get a decent loading times for debugging. To quote a GDB developer: "I would be reluctant to debug KDE on something with <1GB RAM."
If the stepping function of the debugger is slow for you, try the following tips:
* Hide local variables. The <tt>Locals</tt> part of the variable tab on the left causes a big slowdown when stepping if you have many local variables. Simple collapse the <tt>Locals</tt> part of the tree, the local variables are then not updated every step. You can still examine variables by using the <tt>Evaluate expression</tt> function.
* Use the patch at http://bugs.kde.org/show_bug.cgi?id=143977. It prevents the update of the framestack widget at each step, speeding up stepping considerably. The patch introduces some minor glitches, which is why it is not yet commited.
{{Note|
KDevelop does not yet support modifing the CMake build system. This means you can not use KDevelop to add or remove files from the project or to change any other aspect of your project's build process.
You need to modify the CMake files by hand and then rerun <tt>cmakekde</tt> instead. Read the [[Development/Tutorials/CMake|CMake tutorial]] to learn how to do this.
}}{{tip|When you work on libraries, you first need to install them before you can test or debug your changes.
Since this is cumbersome and time consuming, you should create symlinks ''(ln -s)'' pointing from the build directory to the installation directory for all affected libraries.
Often, even simple programs use libraries internally, for example the settings dialog of Konsole is really a library.}}[[Category:KDE4]]