DLL dependency graphs
Producing graphs of the dependencies between Window DLLs (dynamic link libraries). The goal is to use this information to make it easy to see if a DLL fails to load if it is likely due to its dependency by showing what it depends on.
Motivation
The motivation for this project was that I was looking into trying to run various Windows programs on Linux with Wine. I started out with a simple Python script which would load the various DLLs. This would let me know if a which DLLs couldn’t be loaded. The problem was it didn’t tell me why they failed and the most common reason was because one of their dependencies (the DLLs that it loads) couldn’t be loaded. The solution I decided to go with to this problem is to build a graph of the DLLs and their dependencies so you could visually see which libraries were causing the most issues.
Process
- Downloads and extracts the Dependencies tool by Lucasg
- Produce JSON output using the
-jsoncommand line argument and the-chainwith-depth 2. The depth argument limits it taking a long time. - Cache the resulting JSON. This speeds up the process on subsequent runs.
- Convert the JSON output to a simplified graph structure where it keeps just enough information to have the nodes and edges themselves.
- Download and extract GraphViz.
- Uses GraphViz to perform transitive reduction using the
tredprogram. This removes the edges between lower-level libraries if there is already a path through it via another library it depends on. Ultimately, this reduces clutter. - Uses GraphViz to create a PNG as well as DOT version with the layout performed (i.e assign positions to the nodes).
- Outputs to Gephi’s JSON format, as the intention was to use it with the Network component of vis.js. However, that library can also do DOT.
The resulting script is dll_dependencies.py.
Example


Wine Project
The DOT graph is then consumed by the script for the Wine project which colours the nodes based on if the library could be loaded or not.
The next time I pick-up this project, I might look at reworking it to make it available to others and write a follow-up post for it.
Future
- Rework
find_dependencies()to use process multiple DLLs in parnell. - Make the DLL load project public as well. It not limited to Wine as it can also be used for the different Window containers base images.