简体   繁体   English

使GraphViz在C ++中作为库工作的困难

[英]Difficulties getting GraphViz working as a library in C++

Am working on a program that will allow a graph of nodes to be displayed and then updated visually as the nodes themselves are updated. 我正在开发一个程序,它将允许显示节点图,然后在节点本身更新时进行可视化更新。 I am fairly new to Visual Studio 2010 and am following the GraphViz guide located at on the GraphViz website in order to get GraphViz working as a library. 我是Visual Studio 2010的新手,我遵循GraphViz网站上的GraphViz指南,以使GraphViz作为库工作。 I have the following code which is taken straight from the pdf linked above. 我有以下代码,这些代码直接来自上面链接的pdf。

#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 compiling I get the following errors which indicate that I do not have it correctly linked. 编译后,我得到以下错误,表明我没有正确链接。

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

Within the VC++ Directories I have 在VC ++目录中我有

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

and

C:\\Program Files (x86)\\Graphviz2.26.3\\lib\\release\\lib in the Library Directories 库目录中的C:\\ Program Files(x86)\\ Graphviz2.26.3 \\ lib \\ release \\ lib

Any help would be greatly appreciated to help get this working. 任何帮助将非常感谢帮助实现这一目标。 Thank you. 谢谢。

You normally need to add the .lib file to the additional input in the first section of the linking area. 您通常需要将.lib文件添加到链接区域的第一部分中的附加输入。

Correction: properties->Linker->Input->Additional Dependencies. 更正:properties-> Linker-> Input-> Additional Dependencies。

Under additional library inputs, you must add the graphviz import library, whatever it's called, that's in the lib dir you added the path to. 在其他库输入下,您必须添加graphviz导入库,无论它被调用,都在您添加路径的lib目录中。 Perhaps graphviz.lib? 也许graphviz.lib?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM