What is the equivalent of Linux's ldd on windows? [closed]
Asked Answered
G

10

121

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

Gasper answered 3/1, 2010 at 2:1 Comment(1)
see also #7379459Ramah
U
65

Here is Dependency Walker.

http://dependencywalker.com/

Ultracentrifuge answered 3/1, 2010 at 2:2 Comment(5)
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.Disclaim
It appears that that has a command line interface: dependencywalker.com/help/html/hidr_command_line_help.htmUltracentrifuge
Syntax looks something like this: depends.exe /c /oc:dependencies.csv /ot:dependencies.txt mydll.dllWaterbuck
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).Atman
Crashes on Windows 10.Lignite
B
69

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
Bannerman answered 8/3, 2012 at 14:44 Comment(1)
This is the best option if you have Visual Studio installed.Burton
U
65

Here is Dependency Walker.

http://dependencywalker.com/

Ultracentrifuge answered 3/1, 2010 at 2:2 Comment(5)
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.Disclaim
It appears that that has a command line interface: dependencywalker.com/help/html/hidr_command_line_help.htmUltracentrifuge
Syntax looks something like this: depends.exe /c /oc:dependencies.csv /ot:dependencies.txt mydll.dllWaterbuck
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).Atman
Crashes on Windows 10.Lignite
H
44

or the GNU tool :

i586-mingw32msvc-objdump -p  *.exe    | grep 'DLL Name:'
Homoousian answered 17/4, 2012 at 15:52 Comment(2)
Can objdump be used to display the full path? I need something recursively and this requires fullpath for each dependant DLLBolding
objdump only shows you what the file contains. It does not attempt to do any path lookup like ldd does.Capybara
S
14

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

Stesha answered 27/4, 2012 at 17:50 Comment(3)
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.Atman
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.Rawls
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.Knawel
S
13

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.

Stroup answered 22/4, 2017 at 8:4 Comment(0)
S
10

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

Stesha answered 27/4, 2012 at 17:25 Comment(2)
Yes, but it is not very accurateRoam
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.Phail
S
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.

Scag answered 30/12, 2016 at 8:3 Comment(2)
Too bad this doesn't show where the dependents are found so you can precisely see which ones are actually used at runtime :(.Spraggins
@Spraggins Process Explorer from SysInternals MS suite has lower-pane view of all DLLs a binary loads including their paths and symbol/dll search.Bonucci
I
7

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

https://github.com/lucasg/Dependencies

Insectivorous answered 28/8, 2020 at 13:34 Comment(0)
Q
5

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

Quoits answered 29/9, 2020 at 9:55 Comment(3)
the complete example like : dumpbin /imports *.dll | find /i ".dll"Flicker
Great addition to old answers!Flicker
This answer could be a comment to the prior answers, just noting that some users might prefer to sue the developer command prompt.Cappuccino
A
0

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/

Alishiaalisia answered 12/8, 2021 at 10:33 Comment(1)
That is ldd bundled with git bash, which was already mentioned in previous answers.Vituperation

© 2022 - 2024 — McMap. All rights reserved.