I'm attempting to run graphviz as a library from CLion in Windows. It's taken me quite a while to get this far and I hope this is the final hurdle. When I run the program I see the following warning and no graph
Warning: Could not load "C:\Program Files (x86)\Graphviz2.38\bin\gvplugin_pango.dll" - can't open the module
I'm running CLion with MinGW 3.22 as the toolchain. CmakeLists and main.c are below. Unfortunately I'm unable to sign up for graphviz forums so I'm hoping somebody here might have some suggestions. So far I've tried -
- Installing and using mingw-64
- Installing an older version of GraphViz (2.28, current is 2.38)
- Including the gvplugin_pango library in cmakelists.txt
- Changing permissions for Graphviz folder to allow full access to Everyone, tested dot -c and works fine
- Set the GVBINDIR env variable to explicitly point to the 2.38 installation
- Tried setting m32 in Cmakelists.txt (not 100% I did this correctly)
CmakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(Learning)
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
set(GRAPHVIZ_INCLUDE_DIR "C:/Program Files (x86)/Graphviz2.38/include/graphviz")
set(GRAPHVIZ_LIB_DIR "C:/Program Files (x86)/Graphviz2.38/lib/release/lib")
set(SOURCE_FILES main.c)
include_directories("${GRAPHVIZ_INCLUDE_DIR}")
add_executable(Learning ${SOURCE_FILES})
find_library(CGRAPH_LIBRARY cgraph HINTS "${GRAPHVIZ_LIB_DIR}" REQUIRED)
find_library(GVC_LIBRARY gvc HINTS "${GRAPHVIZ_LIB_DIR}" REQUIRED)
target_link_libraries( Learning ${CGRAPH_LIBRARY} ${GVC_LIBRARY} )
Main.c
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <gvc.h>
#include <cgraph.h>
int main() {
Agraph_t *graph;
Agnode_t *nodeA, *nodeB;
Agedge_t *edge1;
Agsym_t *symbol1;
GVC_t *gvc;
gvc = gvContext();
graph = agopen( "graph", Agdirected, NULL);
nodeA = agnode(graph, "nodeA", 1);
nodeB = agnode(graph, "nodeB", 1);
edge1 = agedge(graph, nodeA, nodeB, 0, 1);
printf("debug");
agsafeset(nodeA, "color", "red", "");
gvLayout(gvc, graph, "dot");
gvRender(gvc, graph, "dot", NULL);
agclose(graph);
return ( gvFreeContext(gvc));
}