Using QtCreator for GRASS C development: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(basic howto)
 
(references)
Line 1: Line 1:
Download, configure and compile GRASS as usually.
Download, configure and compile GRASS as usually <ref name="compile">[[Compile and Install]]</ref>.
 
QtCreator can be used for GRASS development in C by using Generic project in QtCreator <ref name="genproj">http://doc.qt.nokia.com/qtcreator/creator-project-generic.html</ref>.


In QtCreator go to
In QtCreator go to
Line 9: Line 11:
Location is directory where your GRASS sources are. Project files will be created in the same directory (it can not be changed).
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.
After pressing Next, QtCreator will scan this directory for all possible source files.
Now you should choose which directories and files you want to include in project.
It is highly recommended to uncheck every directory which you don't need.
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.
This applies especially to modules because modules' local include files can contain declarations which can confuse QtCreator's source completion.
You will probably need only include and lib directories and if you are working on a module, you will need also your module directory.
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:
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:
Line 17: Line 20:
  dist.(...)/include/grass
  dist.(...)/include/grass


You can also apply filters to exclude particular file patterns.
You can also apply filters to exclude particular file patterns, e.g.:


  *.tcl; *.po; *.sh; *.m
  *.tcl; *.po; *.sh; *.m
Line 33: Line 36:
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.
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.
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.
Since QtCreator can do indentation pretty well, it is easy to forget run indentation script, so do not forget to run it.


References
 
http://doc.qt.nokia.com/qtcreator/creator-project-generic.html
== References ==
 
<references/>

Revision as of 10:43, 24 May 2012

Download, configure and compile GRASS as usually [1].

QtCreator can be used for GRASS development in C by using Generic project in QtCreator [2].

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).

After pressing Next, QtCreator will scan this directory for all possible source files. Now you should choose which directories and files you want to include in project. 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 source completion. 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:

dist.(...)/include/grass

You can also apply filters to exclude particular file patterns, e.g.:

*.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.


References