[GRASS-user] Setting GRASS environment variable in a C program
    Glynn Clements 
    glynn at gclements.plus.com
       
    Fri May 21 10:59:21 EDT 2010
    
    
  
rabotin wrote:
> i'm trying to access to my grass data without launching an active grass 
> session with a c program. I'm encoutering issues with the GRASS 
> environment variables definitions.
>     // Setting the grass environment
>     G__setenv("GISDBASE","/home/rabotin/grassdata");
>     G__setenv("LOCATION_NAME","Roujan");
>     G__setenv("MAPSET","PERMANENT");
>     G__setenv("MAPSET","simon9");
> 
>   
>     G_gisinit(argv[0]);
>     std::cout << G_getenv(G_gisdbase()) << std::endl;
>     std::cout << G_getenv(G_location()) << std::endl;
>     std::cout << G_getenv(G_mapset()) << std::endl;
> }
> 
> When launshing this script in command terminal (outside an active grass 
> session), I've got a segmentation fault.
You need to set the GISRC environment variable before you can access
GRASS settings with G_getenv() or G_setenv(). You will also need to
set GISBASE to the root directory of the GRASS installation so that
data files can be located.
There is a list of environment variables used by GRASS in the file
$GISBASE/docs/html/variables.html.
-- 
Glynn Clements <glynn at gclements.plus.com>
    
    
More information about the grass-user
mailing list