# 'gvLayout' crashing

**URL:** <https://forum.graphviz.org/t/gvlayout-crashing/2700>\
**Category:** Dev\
**Created:** [February 6, 2025, 10:42pm UTC](https://forum.graphviz.org/t/gvlayout-crashing/2700 "2025-02-06T22:42:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![sprezzatura](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/sprezzatura/32/1815_2.png) [@sprezzatura](https://forum.graphviz.org/u/sprezzatura)\
**Post date:** [February 14, 2025, 7:53pm UTC](https://forum.graphviz.org/t/gvlayout-crashing/2700/2 "2025-02-14T19:53:47Z")

</div>

I’ve made some progress. The following program builds & runs fine in Visual Studio:

```auto
// TestGraphviz.cpp
//

#include "pch.h"
#include <iostream>
#define GVDLL // https://stackoverflow.com/questions/77733103/cant-use-graphviz-as-a-library-in-c
#include <F:\Program Files\Graphviz\include\graphviz\gvc.h>

int main()
{	char MyGraf[] = "MyGraf", label[] = "label", style[] = "style", fillcolor[] = "fillcolor", color[] = "color", 
		fontcolor[] = "fontcolor", shape[] = "shape", fontname[] = "fontname", fontsize[] = "fontsize", N1[] = "N1", N2[] = "N2",
		empty[] = "";
    std::cout << "Hello World!\n"; 
	GVC_t *gvc = gvContext();
	if(gvc == nullptr)
		return 0;
	std::cout << "\ngvc " << gvc << "\n";
	Agraph_t *graf = agopen(MyGraf, Agdirected, nullptr);
	if(graf == nullptr)
		return 0;
	std::cout << "graf " << graf << "\n";

	Agsym_t *attr = agattr(graf, AGNODE, label, "Default label");
	agattr(graf, AGNODE, style, "filled");
	agattr(graf, AGNODE, fillcolor, "white");
	agattr(graf, AGNODE, color, "black");
	agattr(graf, AGNODE, fontcolor, "black");
	agattr(graf, AGNODE, shape, "box");
	agattr(graf, AGNODE, fontname, "Arial");
	agattr(graf, AGNODE, fontsize, "12");
	
	Agnode_t *n1 = agnode(graf, N1, 1);
	if(n1 == nullptr)
		return 0;
	int r1 = agset(n1, label, "Node 1");
	
	Agnode_t *n2 = agnode(graf, N2, 1);
	if(n2 == nullptr)
		return 0;
	int r2 = agset(n2, label, "Node 2");

	Agedge_t *e = agedge(graf, n1, n2, empty, true);	
	if(e == nullptr)
		return 0;
	
	gvLayout(gvc, graf, "dot");
	std::cout << "n1 " << n1 << ND_label(n1)->text << " r1 " << r1 << "\n";
	std::cout << "n2 " << n2 << ND_label(n2)->text << " r2 " << r2 << "\n";
	
	std::cout << "\n" << ND_pos(n1) << ND_label(n1)->text << "\n";
	return 0;
}

```

You need to link `cgraph.lib` and `gvc.lib`

However, the same code crashes at `gvLayout` when built with Qt 5.13. I link `cgraph.lib` and `gvc.lib`. I’ve tried with and without `cgraph++.lib`, `gvc++.lib` and `cdt.lib`.

I’d attach the source and project files if they let me.

Any Qt’ers out there? Can you reproduce the problem?

---

_[View the full topic](https://forum.graphviz.org/t/gvlayout-crashing/2700)._
