Using QtCreator for GRASS C development: Difference between revisions
⚠️Wenzeslaus (talk | contribs) (→Samples: .files and .includes) |
⚠️Wenzeslaus (talk | contribs) (sections and formatting) |
||
Line 1: | Line 1: | ||
''QtCreator can be used for GRASS development in C by using QtCreator's Generic project <ref name="genproj">Qt Reference Documentation: QtCreator, Setting Up a Generic Project, http://doc.qt.nokia.com/qtcreator/creator-project-generic.html</ref>.'' | |||
== First steps == | |||
Download, configure and compile GRASS as usually <ref name="compile">[[Compile and Install]] GRASS</ref>. | Download, configure and compile GRASS as usually <ref name="compile">[[Compile and Install]] GRASS</ref>. | ||
In QtCreator go to | In QtCreator go to | ||
Line 10: | Line 13: | ||
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). | ||
== Managing files == | |||
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. | ||
Line 30: | Line 35: | ||
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. | ||
== Building == | |||
In order to compile GRASS it is necessary to change compilation settings. | In order to compile GRASS it is necessary to change compilation settings. | ||
Line 35: | Line 43: | ||
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 <tt>all</tt> 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. |
Revision as of 09:00, 11 June 2012
QtCreator can be used for GRASS development in C by using QtCreator's Generic project [1].
First steps
Download, configure and compile GRASS as usually [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).
Managing 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. 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.
Building
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.
Samples
File project_name.files:
dist.x86_64-unknown-linux-gnu/include/grass/defs/arraystats.h ... dist.x86_64-unknown-linux-gnu/include/grass/waterglobs.h lib/raster/align_window.c ... lib/raster/zero_cell.c raster/r.mymodule/main.c
File project_name.includes:
include include/defs include/iostream include/vect lib/raster dist.x86_64-unknown-linux-gnu/include
References
- ↑ Qt Reference Documentation: QtCreator, Setting Up a Generic Project, http://doc.qt.nokia.com/qtcreator/creator-project-generic.html
- ↑ Compile and Install GRASS