Graphviz - Could not load gvplugin_pango.dll
Asked Answered
C

2

7

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));
    }
Chandrachandragupta answered 21/8, 2017 at 0:59 Comment(0)
B
0

The warning might be caused by a missing runtime dependency, the pango library. You could try installing the appropriate pango or pangocairo package for your mingw setup to see if that resolves the issue.

Let me know if that works!

Bartizan answered 24/8, 2017 at 6:38 Comment(1)
I wasn't able to find a pango library in the mingw installation manager, is there somewhere else I should be looking?Chandrachandragupta
I
-1

I'm not familiar with mingw32, or a big fan of it, but it appears you need to to determine that gvplugin_pango.dll and its dependencies are loadable.

In Unix you would use a utility to do this but it appears there's no "ldd" or "otool" to help with this in mingw (really?)

The following stackoverflow article suggests literally grepping the libraries for Finding DLLs required of a Win exe on Linux (cross-compiled with mingw)?

That article points to this utility from 2015: https://github.com/gsauthof/pe-util and there is something fancier called "Dependency Walker" http://www.dependencywalker.com

Sorry for the trouble.

Inhabit answered 24/8, 2017 at 12:0 Comment(1)
Really, what Linux/Unix has to do with this question? Why should there be a stock utility/program to read portable executable dependencies in Linux/Unix? I am surprised by your surprise... Dependency Walker is a Windows program that reads all the portable executable dependencies; it is very old but it still holds pretty well.Tondatone

© 2022 - 2024 — McMap. All rights reserved.