Hi Chris, Thanks. I had already done that - but it still seg. faults. I did an objdump on the librrd.so file and saw that it was linking to glibc2.0 getopt_long function. Is that correct ? (since I saw other definitions for the getopt_long in getopt1.c)
Thanks. Ashok. Chris Carton wrote: > >===== Original Message From Ashok Mandala <[EMAIL PROTECTED]> ===== > >Hi, > > > >I am trying to use the "C" API for the rrd functionality to > >create/update rrd files. I have created the proper argument list that > >rrd_create expects, but I get a segmentation fault from rrd_create when > >I try to use it. I have stepped through the code using gdb and have > >followed it to the point in rrd_create.c where it calls getopt_long() - > >there it issues a segmentation fault when I try to step into it. I saw > >some code for getopt_long() definition in getopt1.c included with > >rrdtool - so this call should have gone to that getopt_long() and the > >source should have opened up. Is the call binding to the libc > >getopt_long() ? Has anyone faced this same problem before ? > > > >Thanks. > >Ashok. > > This is a common stumbling block people run into. These functions really > shouldn't have been designed to assume that they are called from the command > line, but ahh well. > > getopt() uses a global variable 'optind' to indicate the next option in the > command line that has to be parsed. Before you can call these rrd functions > you need to set this variable to 0. > > Declare it like this: > extern int optind; > > Then set it to zero just prior to calling any rrd_* functions. > > This should fix the problem. > > Chris -- Unsubscribe mailto:[EMAIL PROTECTED] Help mailto:[EMAIL PROTECTED] Archive http://www.ee.ethz.ch/~slist/rrd-developers WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
