Novell Home

Using KDevelop

From Developer Community


   This article is a stub. If you have experience with or knowledge about this topic you can help by adding to it.

Contents

Installing KDevelop

Creating A New Project

This section describes the method used to create the Fissle project.

First off, of course, make sure that KDevelop is running. Once it is running:

  • Navigate to the Project menu and select "New Project"
  • Expand C++ in the resulting dialog box
    • You will see several options of types of C++ applications you can create.
    • For a default C++ application select "Simple Hello world program".
  • Enter the name of your application in the "Application name" box (i.e. "fissle").
  • Enter the path where you want this project to reside in the "Location" box. Note that a subdirectory with the name of your project will be created in this directory.
  • Click Next.
  • Enter the correct identifying information.
  • Enter a version number in the "Version" box.
  • Select a license for your project. See Choosing an Open Source License for tips.
  • Select a source code repository. I chose Subversion. The Fissle project is already on Novell Forge so I want to point the project to the Subversion repository on Forge. I include the URL "svn+ssh://matt_ryan@forgesvn1.novell.com/svn/fissle/trunk/fissle" in the box labeled "Repository", but since I have no source code to check in, and since there is no source code on the project, I select the radio button "Don't do anything".
  • Click Next.
  • The next screens offer a license template for me to add to all my code files. This is based upon the license I chose (BSD for fissle). This template will automatically be added to every file, to make sure they are all covered under the license I chose. I edit the template as appropriate (year, owner, e-mail).
  • Click Finish.

This automatically creates a new workspace for my project. One of the great things about KDevelop is that it automatically sets up my project for use with the GNU Autotools. All of the prerequisite files that I need are in place.

Changing Build Options

At some point you will probably need to make changes to the build options of your application. For example, you may want to change the compilation flags for a certain level of error control, or to add include directories or libraries to the build command for your application. In KDevelop, you do this through the Project Menu.

In the menu, select "Project->Project Options", and then select "Configure Options" in the left of the dialog box. This box lets you set the options based upon language as well as build configuration (debug, optimized, etc.).

As an example, suppose that I want to make use of the CommonC++ library in my code. I want to include a new include file path in the build, so this goes into the text box labeled C/C++ preprocessor flags (CPPFLAGS):

 -I/usr/include/cc++2 

I also want to include some libraries for the linker; the information for this goes in the box labeled Linker Flags (LDFLAGS):

 -lccext2 -lccgnu2 -L/usr/lib -lxml2 -lz -lpthread -lm -lz -ldl -lrt -pthread 

When I develop in C++, I like to be very strict in my warnings to help keep my code free from errors. So now I click on the C++ tab in the dialog box which will give me a text box to enter specific flags for the compiler itself. In the box labeled Compiler Flags (CXXFLAGS), I notice that there are already some flags in it for the debug configuration:

 -O0 -g3 

I'm going to add two more flags here. One of these flags will turn on "all warnings which are desirable for normal code" as explained in the GCC Manual - Preprocessor Options, which actually means most warnings, but this is suitable for us. The other flag I want will enforce the language standard. So now this box says:

 -O0 -g3 -Wall -pedantic 

Building Your Project

In the menu, select "Build->Build Project", press F8, or click on the toolbar button to build your project. If this is the first build, KDevelop will ask if you want to run the autotools and configure first. Select yes and let the configuration run.

After configuration, KDevelop will build your application. The output of your build job appears in the status window below. KDevelop supports different build configurations; the default configuration is "debug", which is great while you are developing the application. Your compiled program will appear in the debug/src directory.

Running Your Application

To run your application, simply click in the menu on "Build->Execute Program" or click on the execute button in the toolbar. Your application will run in a separate window.

Novell® Making IT Work As One

© 2008 Novell, Inc. All Rights Reserved.