Difference between revisions of "Using QtCreator for GRASS C development"

From GRASS-Wiki
Jump to: navigation, search
(references)
(formatting)
Line 7: Line 7:
 
  File -> New File or Project -> Other Project -> Import Existing Project
 
  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.
+
and fill Project name. Choose something which allows you to recognize these files easily, e.g. not just <tt>grass</tt>.
 
Separate projects are usually created for separate modules if you are working on a module.
 
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).
 
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.
+
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.
 
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 source completion.
+
This applies especially to modules because modules' local header 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 <tt>include</tt> and <tt>lib</tt> 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 header files by adding dist include directory to QtCreator project. This directory is here:
  
 
  dist.(...)/include/grass
 
  dist.(...)/include/grass
 +
 +
Now it is possible that you will experience problems with changing header files. It is always caused by editing file in dist directory instead of original source file because QtCreator's source browsing functions now bring you to wrong files. So if you are editing header file be sure that this file is in source code directory.
  
 
You can also apply filters to exclude particular file patterns, e.g.:
 
You can also apply filters to exclude particular file patterns, e.g.:
Line 24: Line 26:
 
  *.tcl; *.po; *.sh; *.m
 
  *.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.)
+
On the last wizard page you have to set ''Add to version control'' to <tt>None</tt>. (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.
+
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.
 
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.
  
Line 33: Line 35:
 
  Projects -> your_project_name -> Build Settings -> Build Steps
 
  Projects -> your_project_name -> Build Settings -> Build Steps
  
In Details uncheck all in Targets field.
+
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.
+
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.
Line 43: Line 45:
  
 
<references/>
 
<references/>
 +
 +
[[Category:Development]]

Revision as of 03:03, 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 header 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 header files by adding dist include directory to QtCreator project. This directory is here:

dist.(...)/include/grass

Now it is possible that you will experience problems with changing header files. It is always caused by editing file in dist directory instead of original source file because QtCreator's source browsing functions now bring you to wrong files. So if you are editing header file be sure that this file is in source code directory.

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

  1. Compile and Install
  2. http://doc.qt.nokia.com/qtcreator/creator-project-generic.html