[rrd-developers] API C (Win32) with DevC++

Andreas Maus a.maus at science-computing.de
Fri Aug 7 07:44:02 CEST 2009


On Thu, Aug 06, 2009 at 06:28:28PM -0700, gabriel_takashi wrote:
> 
> Hi,
> I??m from Brazil. I??m studying about RRDTools API C with win32 (DevC++).
Hi.

[... snipp ...]

> int main(int argc, char *argv[])
> {
> 
>   char *rrd_argv[7];
>   int rrd_argc=6;
>   
>   rrd_argv[0]="create";
>   rrd_argv[1]="C:\\RRDTool\\target.rrd";
>   rrd_argv[2]="--start 1023654125";
>   rrd_argv[3]="--step 300";
>   rrd_argv[4]="DS:mem:GAUGE:600:0:671744";
>   rrd_argv[5]="RRA:AVERAGE:0.5:12:24";
>   rrd_argv[6]="RRA:AVERAGE:0.5:288:31";
> 
>   int rrd_ret=rrd_create(rrd_argc, rrd_argv);
>   
>   printf("Resultado: %d\n",rrd_ret);
>   system("PAUSE");	
>   return 0;
> }
> 
> //=========main.c================
> 
> 5??) It compile, but don??t create the file C:\RRDTool\target.rrd
>     When I execute this program:
> 
> http://www.nabble.com/file/p24847392/imgrun.png 
>
> Why this???????
*ahem*
There are several errors in your program:
[...snipp ...]
rrd_argv[2]="--start 1023654125"; 
rrd_argv[3]="--step 300"; 
[... snipp ...]
"--start 1023654125" is NOT ONE option but TWO ("--start","1023654125").
The same goes for "--step". Read the error message of your program.
 
Next thing I mention is that your rrd_argv array is not NULL terminated.
(It _may_ work but usually your heapspace is NOT initialized to zero).

> ==>> My program (test.exe) is in the same place (C:\RRDTool) as rrdtool.exe
> (C:\RRDTool\rrdtool.exe)
*aeh* what do you mean? This is not necessary ...

> ==>> I don??t know where it (my program test.exe) will find rrdtool.exe,
> because I didn??t install RRDTool, I only unzip this to a folder. So there
> isn??t any PATH with RRDTools place...
Of couse you don't need rrdtool.exe! You are linking against the library.

Just take a look in the source code of the corresponding function (rrd_create.c
in this case) and you will see what the code expects (e.g. a NULL terminated
array).

HTH,

Andreas.

P.S.: Why do you system() calls in your code ?

-- 
Dipl.-Ing. Andreas Maus             science+computing ag
System Administration               Hagellocher Weg 73
tel.: +49 7071 9457 671             72070 Tuebingen, Germany
fax: +49 7071 9457 411              www.science-computing.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20090807/fda039c1/attachment.bin 


More information about the rrd-developers mailing list