Slt, je dois utiliser graphviz (bibliotheque c) dans un programme cpp comme une bibliotheque. Je sais que je dois utiliser extern "C" mais je ne sais pas pourquoi ça ne focntionne pas, je dois mal faire quelque chose !!! voici mes fichiers

/********demo.cpp********/

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <gvc.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
 
int main(int argc, char **argv)
{
 
   Agraph_t *g;
   Agnode_t *n, *m;
   Agedge_t *e;
   Agsym_t *a;
   GVC_t *gvc;
   /* set up a graphviz context */
   gvc = gvContext();
   /* parse command line args - minimally argv[0] sets layout engine */
   gvParseArgs(gvc, argc, argv);
   /* Create a simple digraph */
   g = agopen("g", AGDIGRAPH);
   n = agnode(g, "n");
   m = agnode(g, "m");
   e = agedge(g, n, m);
   /* Set an attribute - in this case one that affects the visible rendering */
   agsafeset(n, "color", "red", "");
   /* Compute a layout using layout engine from command line args */
   gvLayoutJobs(gvc, g);
   /* Write the graph according to -T and -o options */
   gvRenderJobs(gvc, g);
   /* Free layout data */
   gvFreeLayout(gvc, g);
 
    /* Free graph structures */
    agclose(g);
    /* close output file, free context, and return number of errors */
    return (gvFreeContext(gvc));
}
 
 
#ifdef __cplusplus
}
#endif
/***********gvc.h**************/

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef                 GVC_H
#define                 GVC_H
 
#include "types.h"
#include "graph.h"
 
#ifdef __cplusplus
extern "C" {
#endif
 
#define dotneato_initialize dotneato_initialize_DEPRECATED_BY_gvParseArgs
#define parse_args parse_args_DEPRECATED_BY_gvParseArgs
 
[...]
 
#ifdef __cplusplus
}
#endif
#endif                  /* GVC_H */
/*************Makefile******************/

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
CC=g++
CFLAGS=-Wall -o2 -g `pkg-config libgvc --cflags`
LDFLAGS=`pkg-config libgvc --libs`
OBJECTS=demo.o
TARGET=demo
all:    $(TARGET)
 
$(TARGET):      $(OBJECTS)
       $(CC) $(LDFLAGS) -o $(TARGET) $(OBJECTS)
clean:
       rm -rf *.o *.*~
/*********Erreurs de compilation****************/

@debian:~/Desktop/Projet/graphviz/graph_cpp$ make
g++ -c -o demo.o demo.cpp
demo.cpp:1:17: error: gvc.h: Aucun fichier ou répertoire de ce type
demo.cpp: In function 'int main(int, char**)':
demo.cpp:11: error: 'Agraph_t' was not declared in this scope
demo.cpp:11: error: 'g' was not declared in this scope
demo.cpp:12: error: 'Agnode_t' was not declared in this scope
demo.cpp:12: error: 'n' was not declared in this scope
demo.cpp:12: error: 'm' was not declared in this scope