17

What tools are available for creating UML Class Diagrams from a set of .h- or .cpp-files?

I am looking for something that...

  • is free
  • runs out of the box on Windows
  • does not require any particular IDE
  • ideally provides a GUI
jopasserat
  • 5,721
  • 4
  • 31
  • 50
Ben
  • 15,938
  • 19
  • 92
  • 138

6 Answers6

7

Dia is a very good open source drawing tool, and cpp2dia creates UML diagrams from .h/.cpp files.

I use it under Linux, I don't know if it runs in other platforms.

There is no GUI for cpp2dia, but its command line usage is very simple.

mskfisher
  • 3,291
  • 4
  • 35
  • 48
pnezis
  • 12,023
  • 2
  • 38
  • 38
  • I've found this page, http://projects.gnome.org/dia/links.html?iframe=true&width=95%&height=95%, that lists tools to create dia diagrams from source-code. However, none of those seem to be available for Windows. Any other tools? – Ben Nov 04 '11 at 21:48
  • While BoUml is able to read my .h files and create a list of my classes, their members and methods in its browser, it claims to have found errors in my code. Also, it doesn't display data members that are of custom data types directly as attributes in the class-diagrams, but instead only displays them as relations between the class-diagrams and the diagram for the custom data type. Any idea how to change that? – Ben Nov 04 '11 at 22:01
  • @webclectic I have played around a bit with **Dia** on Windows and it is a really nice and straightforward tool! You said you are using it on Linux, how hard is it to setup/use for someone with *very* little Linux experience? --- All I want is reading-in .cpp or .h files and creating diagrams from them. Not much fancyness required. --- I've been thinking that I might be able to use it on one of the Linux boxes at Uni... – Ben Nov 05 '11 at 08:59
  • Try virtual box and install a simple Linux distro like Ubuntu in windows. It is very straight forward. You can play with it and if you like install it on your hard drive. – pnezis Nov 05 '11 at 09:01
  • Thx. So about the **cpp2dia**, how hard would that be to setup and use? Any rough estimate of how long it takes from downloading to finished diagram if one uses it for the first time? (I'm just a bit sceptic because I've already tried ~10 tools which all didn't work out for one or another reason). – Ben Nov 05 '11 at 09:06
  • 1
    If you start from scratch you should have your first diagram in about two hours. This includes installing ubuntu in a virtual machine, installing dia and cpp2dia, and applying it to your code. Installing dia is just a command under ubuntu `sudo apt-get install dia` . cpp2dia needs ctags and graphviz so install them as well : `sudo apt-get install exuberant-ctags graphviz` . Then download cpp2dia and read the INSTALL it is fairly simple. Finally move to the folder with your code and execute it... – pnezis Nov 05 '11 at 09:23
  • 2
    I have 2 files mkvparser.cpp mkvparser.hpp. Could you explain how to use dia or cpp2dia? – xXx_CodeMonkey_xXx Jun 01 '12 at 08:44
  • Could you tell us an example of how to use dia2cpp there seems to be no documentation or examples at all! – AL-ROBOT Jun 15 '17 at 08:21
  • apart from the regular Class diagrams what other UML diagrams could be generated using [Dia.](http://live.gnome.org/Dia) – Harsha J K Apr 03 '18 at 21:02
5

About Bouml

it claims to have found errors in my code

the reverse only accept 'true' C++, there is no preprocessor step, so any use of a macro in a class definition or an operation definition produces an error.

it doesn't display data members that are of custom data types directly as attributes

the reverse produces relations the more it is possible, an attribute is used when the type is not a known class or not a class (eg 'int').

don't do several separated reverses, do one reverse specifying several top directories to reserve (each specified directory is traversed recursively)

Bruno Pagès (author of Bouml)

3

I've developed a tool called Doxygraph which can parse the XML generated by Doxygen and turn it into an interactive UML class diagram which you can view in a web browser or import into any software that can read Graphviz "dot" files.

Oktalist
  • 14,336
  • 3
  • 43
  • 63
3

I haven't tried this but Umbrello seems like a viable candidate: http://uml.sourceforge.net/ It is built on top of KDE libraries so it should run on Linux/Windows/Mac.

Roman Kutlak
  • 2,684
  • 1
  • 19
  • 24
  • I tried Umbrello and I would recommend it. You can import source code of various languages into it, but it wont automatically create UML CD for you. HOWEVER, you can easily drag & drop items you need to display from imported tree and Umbrello will display their 'guts' AND even associate them for you as soon as you get 2 associated items on screen. See this post: https://stackoverflow.com/questions/9296708/automagically-create-class-diagram-from-java-code-in-umbrello – Sold Out Jan 23 '20 at 10:21
2

You can try ArgoUML which is free, has a nice GUI and is written in Java so can be run painless on any system.

It is able to generate C++ from UML diagrams; however, reverse engineering of C++ source code is handled by a sub-project for the moment. The latest snapshot of this tool can be downloaded from the source repository. Yet, this tool is still in development, so it might not work as you would expect.

Luc Touraille
  • 79,925
  • 15
  • 92
  • 137
jopasserat
  • 5,721
  • 4
  • 31
  • 50
1

I have implemented a module for StarUML that provides incremental reverse engineering of C++. It provides support for std containers also. It still under development but you may want give it a try. http://starumlcmodule.sourceforge.net.

acampesino
  • 11
  • 1