118

What is the equivalent of Linux's ldd on Windows?

fduff
  • 3,671
  • 2
  • 30
  • 39
WilliamKF
  • 41,123
  • 68
  • 193
  • 295

10 Answers10

65

The dumpbin command can be useful for many things, although in this case dependency walker is probably a little more verbose.

dumpbin /dependents some.dll

Example output:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Team Tools\Static Analysis Tools>dumpbin /dependents StanPolicy.dll

Dump of file StanPolicy.dll

File Type: DLL

Image has the following dependencies:

mscoree.dll

Summary

    2000 .reloc
    2000 .rsrc
   1E000 .text
Kevin
  • 2,761
  • 1
  • 27
  • 31
David St Denis
  • 813
  • 6
  • 9
63

Here is Dependency Walker.

http://dependencywalker.com/

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • 12
    does anything like ldd exist, for command line only? Looking for something I can use from a prompt. Prefer a small light command, preferably without extra DLLs. – J. M. Becker Oct 17 '11 at 14:49
  • 2
    It appears that that has a command line interface: http://www.dependencywalker.com/help/html/hidr_command_line_help.htm – Daniel A. White Oct 17 '11 at 14:54
  • 3
    Syntax looks something like this: depends.exe /c /oc:dependencies.csv /ot:dependencies.txt mydll.dll – Boinst May 21 '13 at 05:13
  • 3
    Dependency Walker works well, but is a jarring change from the simplicity of ldd (especially if you're used to scripting a tool consume its output and do, say, packaging tasks automatically with it). – zxq9 Jun 27 '15 at 07:53
  • 4
    Crashes on Windows 10. – mikemaccana May 31 '19 at 21:39
43

or the GNU tool :

i586-mingw32msvc-objdump -p  *.exe    | grep 'DLL Name:'
whoan
  • 8,143
  • 4
  • 39
  • 48
RzR
  • 3,068
  • 29
  • 26
  • 1
    Can objdump be used to display the full path? I need something recursively and this requires fullpath for each dependant DLL – INS Jan 24 '13 at 08:26
  • 4
    objdump only shows you what the file contains. It does not attempt to do any path lookup like `ldd` does. – jørgensen Jul 17 '14 at 12:35
14

If you're using wine and not real Windows, you can use WINEDEBUG=+loaddll wine <program>.

Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196
  • 7
    Developing against Wine to target Windows struck me as so strange an idea I had to give it a try (I primarily target Linux)... and actually it is working out *far* smoother than I expected for prototyping. Very, very cool. – zxq9 Jun 27 '15 at 07:49
  • Re: development using Wine instead of Windows: note that what works in Wine won't necessarily work on real Windows. I learned this when I forgot to call `GdiplusStartup`, and GDI+ worked without problems in Wine, while on Windows it didn't. I only noticed this mistake after having debugged the program in Wine, trying next to run it in Windows. – Ruslan Jun 03 '17 at 19:29
  • I test things on Wine all the time, just to avoid restarting and changing OS. However, it's good practice before a major release--or any time you've done something that feels even a little suspicious--to try it out on Windows native as well. – Michael Macha Nov 20 '20 at 13:45
11

Newer versions of Git on Windows come packaged with something called Git BASH, which emulates many useful Unix commands including ldd.

It appears that it reports only libraries that can be found. So you can use this to get an overview of where the used libraries are located, but not which are missing.

Machta
  • 1,656
  • 2
  • 16
  • 28
10

There is now an ldd in Cygwin. If you have a very old Cygwin version, you will have to use cygcheck.

Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196
  • 2
    Yes, but it is not very accurate – Stef Oct 03 '15 at 16:47
  • Still not very accurate in 2023 - when I run it over and over again on an MSYS2/UCRT executable developed for a customer (that doesn't change at all...), I'll usually get something between 35 and 40 DLLs listed. Every now and then I even get the correct 41 dependencies. – Andrew Henle Jan 30 '23 at 19:52
8

I guess the Windows Developer way to do this is to use dumpbin /dependents source.exe. If you have Visual Studio installed you can find it here: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\dumpbin.exe.

JohnnyFromBF
  • 9,873
  • 10
  • 45
  • 59
  • 3
    Too bad this doesn't show where the dependents are found so you can precisely see which ones are actually used at runtime :(. – rubenvb Jul 30 '17 at 12:12
  • @rubenvb Process Explorer from SysInternals MS suite has lower-pane view of all DLLs a binary loads including their paths and symbol/dll search. – Kevin Mar 05 '20 at 21:34
6

For Windows 10 you can use Dependencies - An open-source modern Dependency Walker

https://github.com/lucasg/Dependencies

dan.lipsa
  • 101
  • 1
  • 2
2

For windows 10, with visual studio 2017, I go in the search bar of windows and type:

"developer Command Prompt for VS 2017" ( a special cmd.exe for Visual studio developer)

This allows to get access to DUMPBIN that should be used with the /IMPORTS tag. For example, in the correct directory:

DUMPBIN /IMPORTS yourfile.exe (others extension may work too)

For me, this list the DLL and the functions used.

Alternatively, you can use the tag \ALL that is much more verbose.

see the microsoft explanation of DUMPBIN:

https://learn.microsoft.com/en-us/cpp/build/reference/imports-dumpbin?view=vs-2019

Example ( with only a part) of the content sended back by the command

Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
Via_fx_24
  • 129
  • 1
  • 5
1

On Windows I use the cmder as terminal for most things (and not powershell/pwsh). For cmder you can simply type "ldd my_executable.exe" and you will see the expected output.

Link to download cmder: https://cmder.net/

Malte Ahl
  • 21
  • 3