250:lab-8:graphvizsoln

From Marks Wiki
Revision as of 05:07, 3 November 2008 by Mark (Sọ̀rọ̀ | contribs) (7 revision(s))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Windows

First off go to line 85 in parsetree.c

If using gcc via command line (ie not cygwin)

Change

static char* DOT_CMD = "dot";

TO:

static char* DOT_CMD = "\"C:/Program Files/ATT/Graphviz/bin/dot.exe\"";

and call the function as normal now

For cygwin: Change

static char* DOT_CMD = "";

TO:

????
  • NOTE: I tried the above change for Cygwin aswell and it worked. Rwan064 11:00, 20 May 2008 (NZST)

Linux

To get the graph printing on linux, you need to install graphviz, and then fix the typo in the code.

If you have a debian based linux, eg Ubuntu, you should be able to install graphviz with this command:

sudo apt-get install graphviz

Otherwise, you can download it from the web, and install it manually.

If you have installed via apt, dot should be installed in one of the path locations. Therefor, you won't need to specify the exact path. "dot" should do.

However, if you have installed manually, find the directory that the "dot" executable resides in, and put that in the DOT_CMD variable. Eg:

static char* DOT_CMD = "/usr/bin/dot";

Now, you have to fix the typo. The version of a function called popen()(it is what is used to call the dot program to render the trees) on the lab machines is an old implementation, and has sloppy mode detection. So, when popen is called with a mode "wt" it works on the lab machines, despite there not being a mode called "wt"(for exactly why this happens, see the APPLICATION USAGE section of this page) However, linux obviously uses a newer implementation, that actually checks modes properly, and only allows "r" and w". So, to get it to work, find the line:

stream = popen( cmd, "wt" );

And change it to:

stream = popen( cmd, "w" );

Bvic005 16:12, 20 May 2008 (NZST)

Notes

Cheers Braedon for the major help last wekk