Howto create, build and run a simple KDevelop4 ProjectDecember 15, 2008 at 12:51 am | Posted in KDevelop | 14 Comments
As recently the number of users of KDevelop4 has grown and apparently there are quite some “newbies” among them (which is good, new users always mean we easily see flaws in our GUI) I’ve decided to do a small howto on creating, building and running a simple CMake based KDevelop4 project.
First of all: I’m using a Qt4 CMake project using just QtCore, which is the closest you get currently to a simple C++ “hello world” project. We currently don’t have good support for QMake and no project templates for plain Makefiles.
You can create new projects via the Project -> New Project menu entry. Note: for this to work you need KDevelop to load all its plugins, as the menu entry and the underlying functionality is provided by a plugin. If you can’t see it, see my What to do when I don’t have New Project post. You should now see this dialog:
The image shows quite a couple of items in the tree, if you install only kdevplatform and kdevelop you’ll only have the C++ part and therein only the Qt subelements. The other entries are provided by kapptemplate, a program found in the kdesdk module. As I said before I’ll be taking the Qt4 CMake Core application, its under C++->Qt (cmake). After that I supply a project name and leave the default destination directory. This now looks like this:
I’ll skip the version-control page and just hit the Finish button. KDevelop now creates and loads the new project. I can now open the “Projects” toolview on the left and see the project. As this is a cmake project (and we suck and haven’t made this easier yet) you need to tell KDevelop a directory where you want to build the project. To do that open the projects configuration by right-clicking onto the entry in the “Projects” toolview and selecting the “Configure Project” context menu entry. You should now see the configuration dialog (I’ve selected the CMake page already):
With the little “+” button you can add a new builddirectory. This should either be a directory where you’ve previously run cmake for this project (which we haven’t done yet) or a non-existing or empty directory. I’ll be using a “build” subdirectory inside the project directory. Now hit the “Run” button and cmake should be run and its output should be printed in the list. The dialog now looks like this:
After clicking “Ok” KDevelop will read and parse the CMakeCache.txt file and show its contents. You can edit it here if you want to.
Now there are two ways of building the project, you can either again right-click the project entry in the tree and select the Install entry from the menu. Or you can use the buildset in the bottom of the Projects toolview. This allows you to build multiple projects (or files/targets/subdirectories) at once, you can simply add the selected entries from the tree by using the “+” toolbutton in the buildset widget. After that you can use one of the three toolbuttons to the left of the “+” button to build, install or clean. The entries in the Project menu to build, install and so on also use the buildset, so they only work when the buildset is not empty. KDevelop will show the output of running make in the bottom toolview. This is how KDevelop now looks after building the project (this project doesn’t support installation):
Now the last part: Running the created executable. Unfortunately this part is still changing a lot, so I’m not sure its working right now, but at least we can do the setup part. Again open the project configuration dialog by right-clicking onto the project entry in the treeview and selecting “Configure Project” from the menu. In the dialog open the “Run Settings” entry, in the run page click on the “+” button and give a name to the run configuration.
Select the “Executable” radiobutton and put the path to the executable (including the executable) into the lineedit. As my project resides in $HOME/testproject and the build directory is a subdirectory of that, the path here is $HOME/testproject/build/src/testproject. I’ve also set a working directory just to be sure this works (hopefully). The configuration can be seen here:
Now you should be able to select this run target under Run->Run Current Target, however it seems this part is currently not working. Lets assume it does, the last step is selecting the entry Run->Execute Program, which would print “Hello World!” into the bottom toolview.
I hope this helps those people trying to use KDevelop4 for the first time, if anybody has question: Just ask us on the mailinglist email@example.com (registration under http://www.kdevelop.org) or join us on freenode in #kdevelop.
Sorry, the comment form is closed at this time.