GRASS and C++: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
mNo edit summary
Line 20: Line 20:
== Notes ==
== Notes ==


When developing C++ code to call a C function you need to specified for the compiler that the gis.h include is C code with:
C++ code that use C shared libraries needs to specify this fact to the compiler. This can be defined with the ''extern "C"'' keyword, in this way:


<source lang="c">
<source lang="c">
Line 28: Line 28:
}
}
</source>
</source>
The C++ compiler will understand that the functions defined in gis.h are coded in C. If it is not specified the linking step will throw an error stating that the symbols for the C functions were not found in the shared library.


== See also ==
== See also ==

Revision as of 09:05, 7 May 2012

(page to be expanded)

Calling GRASS library functionality in C++

For working examples, see:

I/O:

Raster data processing

Image processing

Visualization:

Notes

C++ code that use C shared libraries needs to specify this fact to the compiler. This can be defined with the extern "C" keyword, in this way:

extern "C" 
{
#include <grass/gis.h>
}

The C++ compiler will understand that the functions defined in gis.h are coded in C. If it is not specified the linking step will throw an error stating that the symbols for the C functions were not found in the shared library.

See also