title: Why does Graphviz fail on gvLayout?
body: <p>Once again, here I am writing C without really knowing what I'm doing...</p>
  
  <p>I've slapped together a simple function that I can call from a C# program that takes a DOT string, an output format, and a file name and renders a graph using Graphviz.</p>
  
  <pre><code>#include "types.h"
  #include "graph.h"
  #include "gvc.h"
  
  #define FUNC_EXPORT __declspec(dllexport)
  
  // Return codes
  #define GVUTIL_SUCCESS          0
  #define GVUTIL_ERROR_GVC        1
  #define GVUTIL_ERROR_DOT        2
  #define GVUTIL_ERROR_LAYOUT     3
  #define GVUTIL_ERROR_RENDER     4
  
  FUNC_EXPORT int RenderDot(char * dotData, const char * format,
          const char * fileName) {
      Agraph_t * g;    // The graph
      GVC_t * gvc;     // The Graphviz context
      int result;      // Result of layout and render operations
  
      // Create a new graphviz context
      gvc = gvContext();
      if (!gvc) return GVUTIL_ERROR_GVC;
  
      // Read the DOT data into the graph
      g = agmemread(dotData);
      if (!g) return GVUTIL_ERROR_DOT;
  
      // Layout the graph
      result = gvLayout(gvc, g, "dot");
      if (result) return GVUTIL_ERROR_LAYOUT;
  
      // Render the graph
      result = gvRenderFilename(gvc, g, format, fileName);
      if (result) return GVUTIL_ERROR_RENDER;
  
      // Free the layout
      gvFreeLayout(gvc, g);
  
      // Close the graph
      agclose(g);
  
      // Free the graphviz context
      gvFreeContext(gvc);
  
      return GVUTIL_SUCCESS;
  }
  </code></pre>
  
  <p>It compiles fine, but when I call it, I get <code>GVUTIL_ERROR_LAYOUT</code>. At first, I thought it might have been how I was declaring my P/Invoke signature, so I tested it from a C program instead, but it still failed in the same way.</p>
  
  <pre><code>RenderDot("digraph graphname { a -&gt; b -&gt; c; }", "png", "C:\testgraph.png");
  </code></pre>
  
  <p>Did I miss something?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>If there's a chance it has to do with how I'm compiling the code, here's the command I'm using:</p>
  
  <pre><code>cl gvutil.c /I "C:\Program Files (x86)\Graphviz2.26\include\graphviz"
      /LD /link /LIBPATH:"C:\Program Files (x86)\Graphviz2.26\lib\release"
      gvc.lib graph.lib cdt.lib pathplan.lib
  </code></pre>
  
  <p>I've been following <a href="http://www.graphviz.org/pdf/libguide.pdf" rel="nofollow noreferrer">this tutorial</a> that explains how to use Graphviz as a library, so I linked to the .lib files that it listed.</p>