# Problems compiling graphviz examples

**URL:** <https://forum.graphviz.org/t/problems-compiling-graphviz-examples/971>\
**Category:** Help\
**Created:** [December 27, 2021, 9:39pm UTC](https://forum.graphviz.org/t/problems-compiling-graphviz-examples/971 "2021-12-27T21:39:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhjar](https://avatars.discourse-cdn.com/v4/letter/r/e56c9b/32.png) [@rhjar](https://forum.graphviz.org/u/rhjar)\
**Post date:** [December 27, 2021, 9:39pm UTC](https://forum.graphviz.org/t/problems-compiling-graphviz-examples/971/1 "2021-12-27T21:39:46Z")

</div>

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](https://graphviz.org/documentation/#sample-programs-using-graphviz) .and i get the following errors when i try to run the make command (OS:fedora 35):

```auto
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:

```

---

<div class="post-metadata">

**Author:** ![rhjar](https://avatars.discourse-cdn.com/v4/letter/r/e56c9b/32.png) [@rhjar](https://forum.graphviz.org/u/rhjar)\
**Post date:** [December 31, 2021, 7:54am UTC](https://forum.graphviz.org/t/problems-compiling-graphviz-examples/971/2 "2021-12-31T07:54:40Z")

</div>

anybody?

---

<div class="post-metadata">

**Author:** ![magjac](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/magjac/32/16_2.png) [@magjac](https://forum.graphviz.org/u/magjac)\
**Post date:** [December 31, 2021, 8:28am UTC](https://forum.graphviz.org/t/problems-compiling-graphviz-examples/971/3 "2021-12-31T08:28:18Z")

</div>

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](https://gitlab.com/graphviz/graphviz/-/blob/main/doc/libgraph/Agraph.pdf) chapter 14 on page 20.

You can find up-to-date examples at [dot.demo · main · graphviz / graphviz · GitLab](https://gitlab.com/graphviz/graphviz/-/tree/main/dot.demo).
