[GRASS-dev] Call Grass modules from C++ code

Vaclav Petras wenzeslaus at gmail.com
Fri Mar 15 07:32:33 PDT 2013

On 15 March 2013 14:58, matteo poletti <pollo1_91 at yahoo.it> wrote:
>> Da: Vaclav Petras <wenzeslaus at gmail.com>
>> Unfortunately it is not suitable. Modules are just programs and their
>> functionality is available only through command line. So, through
>> library calls, you can only use the core functionality in C and C++.
> Finally,
>  I've decided to follow this approach: I will use only the core
> functionalities including the core library with the keyword extern.
>> However, calling grass modules is convenient in Python. If Python is
>> acceptable for you it is worth consider it. There are several ways how
>> to access grass functionality including modules from Python [1].
> Usually I use Python for everything, but this time I need performance :-)

Hi, thank you for sharing your decisions.

One more thing comes in my mind: Cython [1]. Unfortunately, I have no
personal experience but some say that it can be much much faster than
Python. The code translates to some messy C, so it could be fast.
Obviously, it will not make faster existing Python code and especially
pygrass.modules but simple functions are probably faster. Not sure if
someone tried Cython with GRASS.

[1] http://www.cython.org/

> Thank you for your answers!
> I guess I'll need some more help digging in the core libraries ;-)
> Bye!
> Matteo

More information about the grass-dev mailing list