(→Setting up KDevelop) |
(Added explaination, what "git clone ..." will do (for git-newcomers like me)) |
||
| (13 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
| − | === KDevelop 3 (outdated by KDevelop 4) | + | == Eclipse == |
| + | |||
| + | {|align="right" | ||
| + | |[[image:Snapshot-eclipse.png|right|thumb|200px|KDE4's ktimetracker loaded as eclipse project]] | ||
| + | |} | ||
| + | This describes how to use Eclipse to develop KDE 4 applications. It has been tested with Eclipse Ganymede and SUSE Linux 11.1 but should work same or similar with every combination. As an example KDE application we use [http://userbase.kde.org/KTimeTracker KTimeTracker] from the kdepim module, other applications should work likewise. | ||
| + | |||
| + | Using this description you will be able to | ||
| + | * update your working copy of KDE source code using the ''svn'' command | ||
| + | * build your KDE module using CMake | ||
| + | * build your KDE application from within Eclipse using Make | ||
| + | * compile and run your application with one click from Eclipse | ||
| + | * get auto-completion when editing KDE source code | ||
| + | * have an overview and navigation about your classes within Eclipse | ||
| + | * have call trees for your functions | ||
| + | |||
| + | === Set up Eclipse with KDE === | ||
| + | |||
| + | * Check your requirements | ||
| + | : Trying with a virtual machine [[User:Tstaerk|I]] had problems starting Eclipse with less than 1 GB RAM. After assigning 3 GB RAM to the virtual machine, Eclipse finally started. | ||
| + | |||
| + | * Install Eclipse | ||
| + | |||
| + | : Download Eclipse IDE for C/C++ developers from http://www.eclipse.org. Unpack it to /home/user/eclipse. | ||
| + | |||
| + | * Install the CDT | ||
| + | |||
| + | : Download the Eclipse IDE for C/C++ Developers (68 MB) from http://www.eclipse.org/cdt/ and unpack it into your Eclipse folder, in our case /home/user/eclipse. | ||
| + | |||
| + | * Download kdepim | ||
| + | |||
| + | : As said, we use kdepim as example here. So, download ("checkout") kdepim using git (for advanced git-usage see [[Development/Git/Configuration]], especially [[Development/Git/Configuration#URL_Renaming|URL-Renaming]]): | ||
| + | <syntaxhighlight lang="bash"> | ||
| + | cd /home/user | ||
| + | git clone git://anongit.kde.org/kdepim | ||
| + | </syntaxhighlight> | ||
| + | : This will check out into /home/user/kdepim. (Our sample setup for this tutorial) | ||
| + | |||
| + | * Compile kdepim | ||
| + | |||
| + | : Compile kdepim so the usual makefiles are present for all kdepim applications. If you have problems doing this, follow our [[Getting Started/Build|build instructions]]. | ||
| + | |||
| + | * Import your project into Eclipse | ||
| + | |||
| + | : Surprise: To import your project, you cannot use "File -> Import". Rather do: File -> New -> C++ Project -> Makefile project -> Empty Project -> un-tag "use default location" -> choose /home/user/kdepim/ktimetracker. Call it "ktimetracker". | ||
| + | |||
| + | * Build your project | ||
| + | : Make sure Project -> Properties -> C/C++ Build -> Builder Settings -> Build location -> Build directory is set correctly. | ||
| + | : Choose Project -> Build Project | ||
| + | |||
| + | * Run the project | ||
| + | : Choose Project -> Properties -> Run/Debug Settings -> New. As project, enter ''ktimetracker'', as C/C++ Application, enter /home/user/kdepim/ktimetracker/ktimetracker. Choose Apply -> Ok -> Ok. Now you can click on the "Run" button and start it. | ||
| + | |||
| + | === Know-How === | ||
| + | |||
| + | ==== Custom builders ==== | ||
| + | |||
| + | If you want to integrate the CMake build step into your build toolchain, you will need to | ||
| + | * create a custom ''builder'' like this: | ||
| + | <syntaxhighlight lang="bash"> | ||
| + | echo "cmake . && make -j4 && make install" >/bin/eclipsebuild | ||
| + | chmod 777 /bin/eclipsebuild | ||
| + | </syntaxhighlight> | ||
| + | * Add your builder | ||
| + | : Choose Project -> Properties -> Builders. Un-tag all existing builders. Click "new" -> Program -> (name it "Builder for KDE"). -> Location: /bin/eclipsebuild -> Working directory /home/user/workspace/myproject1/kdepim. | ||
| + | |||
| + | * Build | ||
| + | : Now you can build your project. Every time you restart eclipse, choose myproject1 -> Project -> Properties -> C/C++ Build -> Ok -> Project -> Build. | ||
| + | |||
| + | ==== Revert what eclipse did ==== | ||
| + | |||
| + | To revert what eclipse did to your project simply run | ||
| + | <syntaxhighlight lang="bash"> | ||
| + | rm -rf .externalToolBuilders/ .project .cproject | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ==== Why Subversion does not work ==== | ||
| + | |||
| + | When using Eclipse's svn plugin and building a KDE program, you will get error messages complaining that your svn binary is too old. If you want to try and change this, here is how you get to that error: | ||
| + | |||
| + | * Install the Subversion plug-ins | ||
| + | : Help -> Software Updates -> Available Software -> Add Site -> http://download.eclipse.org/technology/subversive/0.7/update-site/ -> Add Site -> http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/ | ||
| + | |||
| + | : Now add it: Subversive Site -> Subversive SVN Team Provider Plugin | ||
| + | |||
| + | : Subversive SVN Connectors Site -> Subversive SVN Connectors -> SVNKit 1.3.0 Implementation (Optional) | ||
| + | |||
| + | * Click on Install | ||
| + | |||
| + | * Restart Eclipse | ||
| + | |||
| + | * Import your KDE module | ||
| + | : Choose File -> New -> Other -> SVN -> Project from SVN -> https://svn.kde.org/home/kde/trunk/KDE/kdepim -> Check out as project configured using the New Project Wizard -> C++ Project -> Makefile Project -> Empty Project. As name, we choose kdepim5 -> Finish | ||
| + | |||
| + | * Set cmake as build environment | ||
| + | : Choose Project -> Properties -> C/C++ Build -> Builder Settings. Un-tag "use default build command", set "cmake" instead. Choose Project -> Properties -> C/C++ Build -> Behavior. Replace "all" by ".". | ||
| + | |||
| + | === See also === | ||
| + | |||
| + | * http://javathreads.de/2008/07/subversion-unter-eclipse-ganymede-konfigurieren/ | ||
| + | * http://nienhueser.de/blog/?p=19 | ||
| + | |||
| + | == QtCreator == | ||
| + | {|align="right" | ||
| + | |[[image:Snapshot-qtcreator.png|right|thumb|200px|KDE4's ktimetracker loaded as QtCreator project]] | ||
| + | |} | ||
| + | |||
| + | Main article: [[Development/Tutorials/Using_Qt_Creator]] | ||
| + | |||
| + | This describes how to use QtCreator to develop KDE 4 applications. It has been tested with QtCreator 1.2.80 and SUSE Linux 11.1 but should work same or similar with every combination. As an example KDE application we use [http://userbase.kde.org/ktimetracker ktimetracker] from the kdepim module, other applications should work likewise. | ||
| + | |||
| + | === Load an existing project === | ||
| + | As discussed here we use ktimetracker as example project. | ||
| + | * Import the CMakeLists.txt file | ||
| + | File -> Open -> kdepim/CMakeLists.txt. | ||
| + | * Configure QtCreator to build only ktimetracker | ||
| + | Projects -> ktimetracker -> build settings -> Add a configuration ktimetracker. | ||
| + | |||
| + | As build directory choose kdepim. As arguments for CMake use e.g. | ||
| + | <syntaxhighlight lang="cmake"> | ||
| + | . -DCMAKE_INSTALL_PREFIX=/usr/local -DLIB_SUFFIX=64 -DCMAKE_BUILD_TYPE=debugfull | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | === Start a KDE project === | ||
| + | To start a new project you need to tell QtCreator to use the KDE libraries when building. So, choose File -> New... and create your project. We will call it ''yourproject'' here. To be able to use KDE's libraries, go to your home directory, change into ''yourproject'' and modify the file ''yourproject.pro''. Add the line | ||
| + | <syntaxhighlight lang="cmake"> | ||
| + | LIBS += -lkdeui | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | == KDevelop 3 (outdated by KDevelop 4) == | ||
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. | 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. 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 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. 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. | ||
| Line 10: | Line 139: | ||
Note that the GDB version which is shipped with '''openSuse 10.3 is broken''', it constantly crashes when examining variables (which KDevelop does automatically). Use the GDB version from [http://download.opensuse.org/repositories/home:/amilcarlucas/openSUSE_10.3/ this repository] instead. | Note that the GDB version which is shipped with '''openSuse 10.3 is broken''', it constantly crashes when examining variables (which KDevelop does automatically). Use the GDB version from [http://download.opensuse.org/repositories/home:/amilcarlucas/openSUSE_10.3/ this repository] instead. | ||
| − | You need to have the kdelibs API documentation locally, which is described in the [[ | + | You need to have the kdelibs API documentation locally, which is described in the [[Development/Tools/apidox|build instructions]]. |
You also need ''ctags'', ''htdig'', ''htmerge'' and ''htsearch''. ''valgrind'' and ''callgrind'' can also be useful. | 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 | + | Be sure you followed the steps in the KDE 4 [[Getting_Started/Build|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 | 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 | ||
| + | </syntaxhighlight> | ||
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 | ||
| − | < | + | <syntaxhighlight lang="bash"> |
cmake $srcFolder -DCMAKE_INSTALL_PREFIX=$KDEDIR \ | cmake $srcFolder -DCMAKE_INSTALL_PREFIX=$KDEDIR \ | ||
-DCMAKE_BUILD_TYPE=debugfull&& \ | -DCMAKE_BUILD_TYPE=debugfull&& \ | ||
make && \ | make && \ | ||
make install; | make install; | ||
| − | </ | + | </syntaxhighlight> |
to | to | ||
| − | < | + | <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&& \ | ||
make && \ | make && \ | ||
make install; | make install; | ||
| − | </ | + | </syntaxhighlight> |
| − | 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/ | + | 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/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. | 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}}: | A simple way to do this is to add the following function to your {{path|.bashrc}}: | ||
| − | < | + | <syntaxhighlight lang="bash"> |
function start3app { | function start3app { | ||
mkdir -p /tmp/$USER-kde | mkdir -p /tmp/$USER-kde | ||
| Line 53: | Line 184: | ||
source $HOME/.bashrc #Reset environment variables again | source $HOME/.bashrc #Reset environment variables again | ||
} | } | ||
| − | </ | + | </syntaxhighlight> |
| − | The ''PATH'' and ''LD_LIBRARY_PATH'' variables are taken from the KDE 3 user, and they may be different on your system. Type < | + | 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</syntaxhighlight> and <syntaxhighlight lang="bash">echo $LD_LIBRARY_PATH</syntaxhighlight> 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 | kde-config --prefix | ||
/opt/kde3 | /opt/kde3 | ||
| − | </ | + | </syntaxhighlight> |
Now you should be able to start KDevelop by typing <tt>start3app kdevelop</tt>. Do that now. | Now you should be able to start KDevelop by typing <tt>start3app kdevelop</tt>. Do that now. | ||
| Line 79: | Line 210: | ||
--> | --> | ||
| − | + | ==== TroubleShooting ==== | |
'''Symptome:''' kdevelop says "cannot talk to klauncher". You cannot open a file. | '''Symptome:''' kdevelop says "cannot talk to klauncher". You cannot open a file. | ||
| Line 86: | Line 217: | ||
export LD_LIBRARY_PATH=/opt/kde3/lib | 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. | 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. | ||
| Line 197: | Line 328: | ||
Now you have completed all essential configuration, congratulations! | 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. | 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." | 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." | ||
| Line 218: | Line 349: | ||
Often, even simple programs use libraries internally, for example the settings dialog of Konsole is really a library.}} | Often, even simple programs use libraries internally, for example the settings dialog of Konsole is really a library.}} | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Contents |
This describes how to use Eclipse to develop KDE 4 applications. It has been tested with Eclipse Ganymede and SUSE Linux 11.1 but should work same or similar with every combination. As an example KDE application we use KTimeTracker from the kdepim module, other applications should work likewise.
Using this description you will be able to
cd /home/user git clone git://anongit.kde.org/kdepim
If you want to integrate the CMake build step into your build toolchain, you will need to
echo "cmake . && make -j4 && make install" >/bin/eclipsebuild chmod 777 /bin/eclipsebuild
To revert what eclipse did to your project simply run
rm -rf .externalToolBuilders/ .project .cproject
When using Eclipse's svn plugin and building a KDE program, you will get error messages complaining that your svn binary is too old. If you want to try and change this, here is how you get to that error:
Main article: Development/Tutorials/Using_Qt_Creator
This describes how to use QtCreator to develop KDE 4 applications. It has been tested with QtCreator 1.2.80 and SUSE Linux 11.1 but should work same or similar with every combination. As an example KDE application we use ktimetracker from the kdepim module, other applications should work likewise.
As discussed here we use ktimetracker as example project.
File -> Open -> kdepim/CMakeLists.txt.
Projects -> ktimetracker -> build settings -> Add a configuration ktimetracker.
As build directory choose kdepim. As arguments for CMake use e.g.
. -DCMAKE_INSTALL_PREFIX=/usr/local -DLIB_SUFFIX=64 -DCMAKE_BUILD_TYPE=debugfull
To start a new project you need to tell QtCreator to use the KDE libraries when building. So, choose File -> New... and create your project. We will call it yourproject here. To be able to use KDE's libraries, go to your home directory, change into yourproject and modify the file yourproject.pro. Add the line
LIBS += -lkdeui
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.
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. You can get KDevelop at the 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. Note that the GDB version which is shipped with openSuse 10.3 is broken, it constantly crashes when examining variables (which KDevelop does automatically). Use the GDB version from this repository instead.
You need to have the kdelibs API documentation locally, which is described in the 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 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
su - kde-develKDevelop 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 .bashrc. Just change
cmake $srcFolder -DCMAKE_INSTALL_PREFIX=$KDEDIR \ -DCMAKE_BUILD_TYPE=debugfull&& \ make && \ make install;
to
cmake $srcFolder -GKDevelop3 -DCMAKE_INSTALL_PREFIX=$KDEDIR \ -DCMAKE_BUILD_TYPE=debugfull&& \ make && \ make install;
After you have done that, re-login so that the changes to the .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 building step). For example, if you want to work on Konsole, which lives in kdebase, you need to run cmakekde in the $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 .bashrc:
function start3app { mkdir -p /tmp/$USER-kde export PATH=/opt/kde3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games export LD_LIBRARY_PATH= export KDETMP=/tmp/$USER-kde export KDEVARTMP=/var/tmp/$USER-kde export KDEHOME=$HOME/.kde export KDEDIR=/usr export KDEDIRS=$KDEDIR export DISPLAY=:0 eval "$@" source $HOME/.bashrc #Reset environment variables again }
echo $PATH
echo $LD_LIBRARY_PATH
kde-config --prefix /opt/kde3
Now you should be able to start KDevelop by typing start3app kdevelop. Do that now.
| Tip |
|---|
| You can start any KDE 3 application with the start3app 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. |
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
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 create it beforehand. Then add the documentation by clicking Add.... In this dialog, use the following settings:
Now add the Qt API documentation, which also must be created beforehand, using the following settings:
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 $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 project(projectname) 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 Make Active Directory entry in the context menu of the File Selector sidetab. With this, you can ignore the other unwanted folders when building and installing. |
| 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 |
| 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 |
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:
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.
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:
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!
Refer to the KDevelop manual for general help using KDevelop. The following section will only deal with special cases for KDE 4.
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:
| 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 cmakekde instead. Read the 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. |