[rrd-users] rrd C Api

Geoff Garside geoff.garside at openhosting.co.uk
Thu Jul 24 12:15:11 CEST 2008


Hi Shirley,
Well you'll need to

    #include <rrd.h>

in your rrd.c file to get the function signatures for rrd_create and so 
on. When you come to compile it you'll need to tell gcc to link the rrd 
library using -lrrd.

It might complain that it can't find either rrd.h or librrd in which 
case you'll need to specify some compiler and linker flags. Depending on 
where your rrd.h and librrd.so are located you'll want something like 
this passed to gcc (the \ indicates a line break for readability, but 
the shell will happily work with it)

    gcc -I/usr/include -I/usr/local/include -L/usr/lib \
        -L/usr/local/lib -lrrd rrd.c

this will create your program in the current directory as a.out. If you 
wanted to call it say "myprog" you would compile it with

    gcc -I/usr/include -I/usr/local/include -L/usr/lib \
        -L/usr/local/lib -lrrd -o myprog rrd.c

The -I flags add directories in which the compiler will search for rrd.h 
and the -L flags add directories in which to search for librrd.so. If 
your rrd.h and librrd.so are in different locations, /opt/local/include 
and /opt/local/lib for example then replace the /usr/local/include and 
/usr/local/lib paths in the above commands with those.

I think that should be enough.

Geoff

zhuxl at lenovo.com wrote:
>
> Hey guys,
> I am repeating my question since i am still struggling for the 
> solution. My question is: I wrote a code rrd.c which calls 
> rrd_create(), now i want to compile and run it. 1) what are the 
> headers i got to include?2) when i compile it using "gcc rrd.c" , what 
> are the flags for linking? I know this sounds an quite naive question 
> for most of you, but since i am new to it, i really appreciate your 
> help. Thanks a lot!
>
> Shirley
> ------------------------------------------------------------------------
>
> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>   



More information about the rrd-users mailing list