View Issue Details

IDProjectCategoryView StatusLast Update
0000443ascendbuild-linuxpublic2011-06-23 10:47
Reporterbobbens 
Assigned Tojohn 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.9.7 
Target Version0.9.8Fixed in Version0.9.8 
Summary0000443: Newer GraphViz versions not compatible with ASCEND code
DescriptionWhile building ASCEND from svn trunk I've found that it never seemed to detect graphviz on my system even though it is installed. It seems like -lgraphviz does not exist but -lgvc does. I manually compiled the testcases scons does and that worked. Modifying SConstruct I was able to get it to detect it, however pygtk was failing to build because it was missing some env variables, specifically:

'GRAPHVIZ_CPPPATH'
'GRAPHVIZ_LIBS'
'GRAPHVIZ_LIBPATH'

It happens to be that these are commented in SConstruct. Uncommenting them and reenabling a bit of code above with the defaults allowed it to then compile cleanly. It seems like those should be enabled especially because with HAVE_GRAPHVIZ pygtk needs them to compile.

I'm attaching the patch which allows it to compile on my Arch Linux. I currently do not have other OS installed to be able to test it on other systems.
TagsNo tags attached.

Relationships

related to 0000375 resolvedjohn graphviz linkage should be dlopen so that it need not be present at runtime 

Activities

2010-03-30 04:35

 

graphviz.diff (2,310 bytes)
Index: SConstruct
===================================================================
--- SConstruct	(revision 2734)
+++ SConstruct	(working copy)
@@ -212,8 +212,8 @@
 	default_with_scrollkeeper=False
 	pathsep = ":"
 		
-	#default_graphviz_libs=["graph","cdt","gvc"]
-	#default_graphviz_libpath = default_libpath
+	default_graphviz_libs=["graph","cdt","gvc"]
+	default_graphviz_libpath = default_libpath
 	#if os.path.exists("/usr/lib/graphviz/libgraph.so"):
 	#	# for Ubuntu 7.04
 	#	default_graphviz_libpath="/usr/lib/graphviz"
@@ -769,25 +769,23 @@
 #		,default_prefix
 #	))
 #
-#	vars.Add(PackageVariable(
-#		'GRAPHVIZ_CPPPATH'
-#		,"Where are your GRAPHVIZ include files? (don't need the final '/graphviz')"
-#		,default_cpppath
-#	))
+vars.Add(PackageVariable(
+	'GRAPHVIZ_CPPPATH'
+	,"Where are your GRAPHVIZ include files? (don't need the final '/graphviz')"
+	,default_cpppath
+))
+vars.Add(PackageVariable(
+	'GRAPHVIZ_LIBPATH'
+	,"Where are your GRAPHVIZ libraries?"
+	,default_graphviz_libpath
+))
+vars.Add(
+	'GRAPHVIZ_LIBS'
+	,"What are your GRAPHVIZ libraries named?"
+	,default_graphviz_libs
+)
 #
 #	vars.Add(PackageVariable(
-#		'GRAPHVIZ_LIBPATH'
-#		,"Where are your GRAPHVIZ libraries?"
-#		,default_graphviz_libpath
-#	))
-#
-#	vars.Add(
-#		'GRAPHVIZ_LIBS'
-#		,"What are your GRAPHVIZ libraries named?"
-#		,default_graphviz_libs
-#	)
-#
-#	vars.Add(PackageVariable(
 #		'GRAPHVIZ_RPATH'
 #		,"What is your GRAPHVIZ rpath for locating libraries at runtime? (only required for old Ubuntu)"
 #		,default_graphviz_rpath
@@ -1425,7 +1423,7 @@
 """
 
 def CheckGraphViz(context):
-	return CheckExtLib(context,'graphviz',graphviz_test_text,ext=".c")
+	return CheckExtLib(context,'gvc',graphviz_test_text,ext=".c")
 
 graphviz_boolean_test = """
 #ifdef __WIN32__
@@ -1444,7 +1442,7 @@
 """
 
 def CheckGraphVizBoolean(context):
-	return CheckExtLib(context,'graphviz',graphviz_boolean_test,ext=".c" \
+	return CheckExtLib(context,'gvc',graphviz_boolean_test,ext=".c" \
 		,testname="graphviz 'boolean' definition"
 	)
 
@@ -2353,7 +2351,7 @@
 		without_graphviz_reason = 'graphviz not found'
 		with_graphviz = False
 		env['WITH_GRAPHVIZ'] = False
-	env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()		
+	env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()
 
 # UFSPARSE
 
graphviz.diff (2,310 bytes)

john

2010-03-30 09:44

administrator   ~0000614

Graphviz detection was recently reimplemented as a SCons 'tool'. See the file 'scons/graphviz.py'.

This tool runs 'pkg-config' to detect the Graphviz package and corresponding compiler flags. Maybe you don't have pkg-config installed, for example? Or maybe the packages have a different name on your distro?

john

2010-03-30 09:45

administrator   ~0000615

What version of Graphviz do you have on your distro?

bobbens

2010-03-30 09:51

reporter   ~0000616

Last edited: 2010-03-30 09:56

I'm using:

extra/graphviz 2.26.3-1 [installed]

Although this could explain the warning I always get:

scons: Reading SConscript files ...
Package libagraph was not found in the pkg-config search path.
Perhaps you should add the directory containing `libagraph.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libagraph' found
SUNDIALS_LIBS = ['sundials_ida', 'sundials_nvecserial', 'm']
...

Before starting to compile.

EDIT: Seems like removing the libagraph reference from scons/graphviz.py does the trick.

john

2010-03-30 10:48

administrator   ~0000617

I have 2.20.2-3ubuntu5 on my Ubuntu 9.10 system. So maybe Graphviz has been changed a bit in recent versions. To do this properly requires understanding how Graphviz has changed and making suitable conditional switches based on the version.

bobbens

2010-03-30 20:21

reporter   ~0000620

Last edited: 2010-03-30 20:22

The best I have found is:

https://mailman.research.att.com/pipermail/graphviz-devel/2008/000836.html

It seems like libagraph is disappearing and there's a new libcgraph taking it's place. I do not have a libagraph but do have a libcgraph. Either way, it doesn't seem like libagraph is actually needed to compile ASCEND because I was able to compile it without it. Maybe you should try removing the libagraph reference in scons/graphviz.py and see if it still works with older graphviz.

EDIT: Also found this:

https://mailman.research.att.com/pipermail/graphviz-devel/2009/000992.html

Which is much more explicit on the subject.

john

2011-02-21 16:27

administrator   ~0000673

I've updated the title of this bug because it's not an Archlinux-only problem. Also present for Ubuntu 10.10 users, as reported by Divyanshu Bandil.

stevemi

2011-06-23 01:33

reporter   ~0000748

Also happens on FC9 (new user)

john

2011-06-23 10:45

administrator  

graph.c (8,942 bytes)

john

2011-06-23 10:45

administrator  

graph.patch (5,186 bytes)
*** graph.c	2011-02-23 16:40:15.000000000 +0530
--- graphnew.c	2011-03-20 12:24:00.158019044 +0530
***************
*** 30,43 ****
  #endif
  #include <ascend/general/platform.h>
  
! #ifdef WITH_GRAPHVIZ
  # ifdef __WIN32__
  #  include <gvc.h>
  # else
  #  include <graphviz/gvc.h>
  # endif
  # define HAVE_BOOLEAN
! #endif
  
  boolean X;
  
--- 30,43 ----
  #endif
  #include <ascend/general/platform.h>
  
! /*#ifdef WITH_GRAPHVIZ
  # ifdef __WIN32__
  #  include <gvc.h>
  # else
  #  include <graphviz/gvc.h>
  # endif
  # define HAVE_BOOLEAN
! #endif*/
  
  boolean X;
  
***************
*** 46,51 ****
--- 46,53 ----
  #include "incidence.h"
  #include <ascend/general/ascMalloc.h>
  #include <ascend/general/panic.h>
+ #include <dlfcn.h>
+ #include <graphviz/gvc.h>
  
  int system_write_graph(slv_system_t sys
  	, FILE *fp
***************
*** 54,60 ****
  	incidence_vars_t id;
  	build_incidence_data(sys, &id);
  
! #ifdef WITH_GRAPHVIZ
  	Agraph_t *g;
  	GVC_t *gvc;
  
--- 56,196 ----
  	incidence_vars_t id;
  	build_incidence_data(sys, &id);
  
! 	void * handle;
! 	handle = dlopen("libgvc.so",RTLD_NOW);
! 	if(handle==NULL) 
! 	{
! 		printf("Graphviz was not found on your system");
! 		return 1;
! 	}
! 		
! 	Agraph_t *g;
! 	Agraph_t *(*agop)(char* , int);
! 	
! 	GVC_t *gvc;
! 	GVC_t *(*gvConte)();
! 
! 	void (*agnodeat) (Agraph_t* , char* , char*);
! 	
! 	*(void **) (&gvConte) = dlsym(handle,"gvContext");
! 	*(void **) (&agop) = dlsym(handle,"agopen");
! 	*(void **) (&agnodeat) = dlsym(handle,"agnodeattr");
! 
! 
! 	unsigned edgecount = 0;
! 	unsigned nodecount = 0;
! 
! 	gvc = (*gvConte)();
! 	g = (*agop)("g",AGDIGRAPH);
! 	(*agnodeat)(g,"shape","ellipse");
! 	(*agnodeat)(g,"label","");
! 	(*agnodeat)(g,"color","");
! 	(*agnodeat)(g,"style","");
! 	
! 	char temp[200];
! 
! 	/* first create nodes for the relations */
! 	unsigned i;
! 	Agnode_t *n, *m;
! 	Agnode_t *(*agno)(Agraph_t* , char*);
! 	void (*ags) (Agnode_t* , char* , char*);
! 
! 	*(void **) (&agno) = dlsym(handle,"agnode");
! 	*(void **) (&ags) = dlsym(handle,"agset");
! 	
! 
! 	for(i=0; i < id.neqn; ++i){
! 		char *relname;
! 		relname = rel_make_name(sys,id.rlist[i]);
! 		sprintf(temp,"r%d",rel_sindex(id.rlist[i]));
! 		n = (*agno)(g,temp);
! 		(*ags)(n,"label",relname);
! 		if(rel_satisfied(id.rlist[i])){
! 			(*ags)(n,"style","filled");
! 			(*ags)(n,"color","blue");
! 		}
! 		ASC_FREE(relname);
! 		nodecount++;
! 	}
! 
! 	/* now create nodes for the variables */
! 	unsigned j;
! 	for(j=0; j < id.nvar; ++j){
! 		char *varname;
! 		varname = var_make_name(sys,id.vlist[j]);
! 		sprintf(temp,"v%d",var_sindex(id.vlist[j]));
! 		n = (*agno)(g,temp);
! 		(*ags)(n,"label",varname);
! 		(*ags)(n, "shape", "box");
! 		if(var_fixed(id.vlist[j])){
! 			CONSOLE_DEBUG("VAR '%s' IS FIXED",varname);
! 			(*ags)(n,"style","filled");
! 			(*ags)(n,"color","green");
! 		}
! 		if(!var_active(id.vlist[j])){
! 			CONSOLE_DEBUG("VAR '%s' IS FIXED",varname);
! 			(*ags)(n,"style","filled");
! 			(*ags)(n,"color","gray");
! 		}
! 		ASC_FREE(varname);
! 		nodecount++;
! 	}
! 
! 	/* now create edges */
! 	const struct var_variable **ivars;
! 	unsigned niv;
! 	char reltemp[200];
! 	Agedge_t *e;
! 	Agedge_t *(*aged)(Agraph_t* , Agnode_t*, Agnode_t*);
! 
! 	*(void **) (&aged) = dlsym(handle,"agedge");
! 
! 	for(i=0; i < id.nprow; ++i){
! 		ivars = rel_incidence_list(id.rlist[i]);
! 		niv = rel_n_incidences(id.rlist[i]);
! 		sprintf(reltemp,"r%d",rel_sindex(id.rlist[i]));
! 		char *relname;
! 		relname = rel_make_name(sys,id.rlist[i]);
! 		CONSOLE_DEBUG("rel = '%s'",relname);
! 		ASC_FREE(relname);
! 		for(j=0; j < niv; ++j){
! 			const struct var_variable *v;
! 			v = ivars[j];
! 			sprintf(temp,"v%d",var_sindex(v));
! 			n = (*agno)(g, reltemp);
! 			m = (*agno)(g, temp);
! 
! 			if(id.v2pc[var_sindex(v)]==id.e2pr[rel_sindex(id.rlist[i])]){
! 				e = (*aged)(g,n,m); /* from rel to var */
! 			}else{
! 				e = (*aged)(g,m,n); /* from var to rel */
! 			}
! 			edgecount++;
! 		}
! 	}
! 
! 	if(nodecount > 300 || edgecount > 300){
! 		ERROR_REPORTER_HERE(ASC_USER_ERROR,"Graph is too complex, will not launch GraphViz (%d nodes, %d edges)", nodecount, edgecount);
! 		return 1;
! 	}
! 
! 
! 	void (*gvLayo)(GVC_t* , Agraph_t*, char*);
! 	void (*gvRend)(GVC_t* , Agraph_t*, char*, FILE*);
! 
! 	*(void **) (&gvLayo) = dlsym(handle,"gvLayout");
! 	*(void **) (&gvRend) = dlsym(handle,"gvRender");
! 
! 
! 	(*gvLayo)(gvc, g, "dot");
! 	(*gvRend)(gvc, g, (char*)format, fp);
! 
! 	printf("\nErrors encountered %s\n",(*dlerror)());
! 	dlclose(handle);
! 
! #if 0//def WITH_GRAPHVIZ
! 
! 
  	Agraph_t *g;
  	GVC_t *gvc;
  
***************
*** 145,155 ****
  	}
  
  	gvLayout(gvc, g, "dot");
! 	gvRender(gvc, g, (char*)format, fp);
  
  #else
! 	ERROR_REPORTER_HERE(ASC_PROG_ERR,"Function system_write_graph not available (GraphViz not present at build-time)");
! 	return 1; /* error */
  #endif
  
  #if 0
--- 281,291 ----
  	}
  
  	gvLayout(gvc, g, "dot");
! 	gvRender(gvc, g, (char*)format, fp); */
  
  #else
! //	ERROR_REPORTER_HERE(ASC_PROG_ERR,"Function system_write_graph not available (GraphViz not present at build-time)");
! //	return 1; /* error */
  #endif
  
  #if 0
graph.patch (5,186 bytes)

john

2011-06-23 10:45

administrator  

SConstruct.patch (483 bytes)
*** SConstruct	2011-03-20 12:35:43.000000000 +0530
--- SConstructnew	2011-03-20 11:24:03.000000000 +0530
***************
*** 902,908 ****
  
  tools = [
  	'lex', 'yacc', 'fortran', 'swig', 'substinfile'
! 	,'disttar', 'graphviz', 'tar','sundials'
  ]
  if platform.system()=="Windows":
  	tools += ['nsis']
--- 902,908 ----
  
  tools = [
  	'lex', 'yacc', 'fortran', 'swig', 'substinfile'
! 	,'disttar', 'tar','sundials'
  ]
  if platform.system()=="Windows":
  	tools += ['nsis']
SConstruct.patch (483 bytes)

john

2011-06-23 10:46

administrator   ~0000749

Added three files as received from Divyanshu Bandil 30 March 2011. These files were used to patch trunk ASCEND code in changeset 3314, changeset 3315, and this bug is now believed to be fixed in trunk.

Issue History

Date Modified Username Field Change
2010-03-30 04:35 bobbens New Issue
2010-03-30 04:35 bobbens Status new => assigned
2010-03-30 04:35 bobbens Assigned To => john
2010-03-30 04:35 bobbens File Added: graphviz.diff
2010-03-30 09:44 john Note Added: 0000614
2010-03-30 09:45 john Note Added: 0000615
2010-03-30 09:51 bobbens Note Added: 0000616
2010-03-30 09:56 bobbens Note Edited: 0000616
2010-03-30 09:56 bobbens Note Edited: 0000616
2010-03-30 10:48 john Note Added: 0000617
2010-03-30 20:21 bobbens Note Added: 0000620
2010-03-30 20:22 bobbens Note Edited: 0000620
2011-02-21 16:27 john Note Added: 0000673
2011-02-21 16:27 john Summary Graphviz not found in Arch Linux => Newer GraphViz versions not compatible with ASCEND code
2011-02-22 11:48 john Relationship added related to 0000375
2011-02-22 17:34 john Target Version => 1.0
2011-06-23 01:33 stevemi Note Added: 0000748
2011-06-23 10:45 john File Added: graph.c
2011-06-23 10:45 john File Added: graph.patch
2011-06-23 10:45 john File Added: SConstruct.patch
2011-06-23 10:46 john Note Added: 0000749
2011-06-23 10:47 john Status assigned => resolved
2011-06-23 10:47 john Fixed in Version => 0.9.8
2011-06-23 10:47 john Resolution open => fixed
2011-06-23 10:47 john Target Version 1.0 => 0.9.8