Difficulties with GraphViz working as a library in C ++

I’m working on a program that will allow you to display a graph of nodes, and then visually update as the nodes themselves are updated. I am new to Visual Studio 2010 and follow the GraphViz tutorial at the address on the GraphViz website to get GraphViz working as a library. I have the following code, which is taken directly from the pdf file above.

#include <graphviz\gvc.h>
#include <graphviz\cdt.h>
#include <graphviz\graph.h>
#include <graphviz\pathplan.h>
using namespace std;

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));
}

After compilation, I get the following errors, which indicate that I do not have the correct link.

1> main.obj: error LNK2019: unresolved external symbol _gvFreeContext referenced in function _main
1> main.obj: error LNK2019: unresolved external symbol _agclose referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _gvFreeLayout referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _gvRenderJobs referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _gvLayoutJobs referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _agsafeset referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _agedge referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _agnode referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _agopen referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _gvParseArgs referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _gvContext referenced in function _main

V++

C:\Program Files (x86)\Graphviz2.26.3\include Include

C:\Program Files (x86)\Graphviz2.26.3\lib\release\lib

. .

+3
2

.lib .

: properties- > Linker- > Input- > Additional Dependencies.

+1

graphviz, , , lib . , graphviz.lib?

+1

Source: https://habr.com/ru/post/1746631/


All Articles