Problems compiling graphviz examples

I want to implement and use Graphviz in my C program,So I started reading its the documentations.However I have even problems with example codes provided by Graphviz itself
sample codes are here .and i get the following errors when i try to run the make command (OS:fedora 35):

cc `pkg-config libgvc --cflags` -Wall -g -O2   -c -o dot.o dot.c
cc `pkg-config libgvc  --libs`  dot.o   -o dot
cc `pkg-config libgvc --cflags` -Wall -g -O2   -c -o demo.o demo.c
demo.c: In function ‘main’:
demo.c:27:15: warning: variable ‘e’ set but not used [-Wunused-but-set-variable]
   27 |     Agedge_t *e;
      |               ^
cc `pkg-config libgvc  --libs`  demo.o   -o demo
cc `pkg-config libgvc --cflags` -Wall -g -O2   -c -o simple.o simple.c
cc `pkg-config libgvc  --libs`  simple.o   -o simple
cc `pkg-config libgvc --cflags` -Wall -g -O2   -c -o example.o example.c
example.c: In function ‘main’:
example.c:25:21: error: ‘AGDIGRAPH’ undeclared (first use in this function); did you mean ‘AGRAPH’?
   25 |     g = agopen("g", AGDIGRAPH);
      |                     ^~~~~~~~~
      |                     AGRAPH
example.c:25:21: note: each undeclared identifier is reported only once for each function it appears in
example.c:25:9: error: too few arguments to function ‘agopen’
   25 |     g = agopen("g", AGDIGRAPH);
      |         ^~~~~~
In file included from /usr/include/graphviz/types.h:36,
                 from /usr/include/graphviz/gvc.h:14,
                 from example.c:2:


It seems that the examples on the web page are obsolete. They seem to be made for a much earlier version of the library named Libgraph. The modern version is Cgraph. See doc/libgraph/Agraph.pdf · main · graphviz / graphviz · GitLab chapter 14 on page 20.

You can find up-to-date examples at dot.demo · main · graphviz / graphviz · GitLab.

1 Like