Wednesday, November 13, 2013

Doxygen on OS X Not Generating Graphviz/dot Files Correctly

I installed the OS X port of Doxygen via the http://www.stack.nl/~dimitri/doxygen/download.html site, which installed directly into my /Applications folder. Since 'dot' was not included with that distribution (which gives a nice pretty graphical display of class hierarchies), I installed graphviz via MacPorts, which installed its files into /opt/local/bin.

I created a new Doxygen project and selected all the options I wanted it to generate. One of the options I selected was in the [Wizard] tab, under the Diagrams topic: "Use dot tool from the GraphViz package". I clicked "Run doxygen" and...

Errors.

Specifically, the log file showed:
    sh: dot: command not found
    error: Problems running dot: exit code=127, command='dot', arguments='"/[path]/Doxygen/html/[filename].dot" -Tpng -o "/[path]/Doxygen/html/[filename].png"'

Most answers that popped up online dealt with the Windows version of Doxygen, but not OS X. Turns out, it's a simple fix. It's looking for /usr/bin/dot which, as I showed earlier, was actually located in /opt/local/bin/dot due to MacPorts.

Switch over to the [Expert] tab, under the Dot topic. Find DOT_PATH and enter /opt/local/bin in that field. If you use the Finder button, which lets you open a dialog window to locate the 'dot' file, it puts in a relative path: ../../../../../opt/local/bin, which actually doesn't always work correctly. Just use the absolute path of /opt/local/bin and you should be good.

Now hitting "Run doxygen" should correctly generate the dependency graphs.

I remember (vaguely) doing something like this a couple years ago, but forgot all the steps, especially the OS X-specific settings (versus the Windows path ones). Hope it helps someone else out there!

No comments:

Post a Comment