Using QtCreator for GRASS C development

From GRASS-Wiki
Revision as of 02:31, 24 May 2012 by Wenzeslaus (talk | contribs) (basic howto)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Download, configure and compile GRASS as usually.

In QtCreator go to

File -> New File or Project -> Other Project -> Import Existing Project

and fill Project name. Choose something which allows you to recognize these files easily, e.g. not just grass. Separate projects are usually created for separate modules if you are working on a module. Location is directory where your GRASS sources are. Project files will be created in the same directory (it can not be changed).

QtCreator will scan this directory for all possible source files. It is highly recommended to uncheck every directory which you don't need. This applies especially to modules because modules' local include files can contain declarations which can confuse QtCreator's syntax completation. You will probably need only include and lib directories and if you are working on a module, you will need also your module directory. However, there is an issue with include directories. Include directory is at different places in source codes and in GRASS distribution directory. You have to help QtCreator to find include files by adding distribution include directory to QtCreator project. This directory is here:


You can also apply filters to exclude particular file patterns.

*.tcl; *.po; *.sh; *.m

On the last wizard page you have to set Add to version control to None. (Warning: If you forgot this step, QtCreator project files will be added to GRASS SVN.)

Once project is created you can add new files through Edit files option in project context menu in project tree. If you open this dialog and you press OK button, all files in marked directories will be added, so this is the way how to add new files from SVN.

In order to compile GRASS it is necessary to change compilation settings.

Projects -> your_project_name -> Build Settings -> Build Steps

In Details uncheck all in Targets field. If you have more than one core, you may want to specify number of cores used by make by setting Make arguments field to -j n where n is number of cores you want to use. You can also change Build directory to run make only for necessary directories. Since QtCreator can do indentation pretty well, it is easy to forget run indentation script, so do not forget to run it.