开发者

Building dependency trees

开发者 https://www.devze.com 2023-02-19 03:07 出处:网络
How do I build a dependency tree using C++? By dependency tree I mean, for example开发者_StackOverflow中文版, checking what files a certain program needs in order to run. By checking that, I could fin

How do I build a dependency tree using C++? By dependency tree I mean, for example开发者_StackOverflow中文版, checking what files a certain program needs in order to run. By checking that, I could find if there are any missing or corrupt files.

How do I do something like that?

edit:

I'm not looking for a program that does it for me!


There is no cross-platform method for calculating dependencies, because this is not actually a C++ problem. It is related to the executable format output by the compiler, and that is different on each platform.

On Linux (and probably other Unices), the ldd command is what you want. This prints out the (recursive) modules that will be required by the executable, and also tells you where they can currently be found on your system.

On Windows, Dependency Walker is an excellent graphical tool that lets you explore all of the DLLs that an executable (or another DLL) depends upon.


Just a suggestion when talking about Windows: you can write a module that catches all the calls to open, read, write, ... a file from your application and builds the list of files requested possibly filtering such files as standard input/output, ports, devices, etc.

You can do this also on Linux (this is even easier than on Windows).

Anyway, I don't realize how you can build an hierarchy (tree). Just in case: you can use this solution in couple with another one (such as ldd, dep walker, etc).

0

精彩评论

暂无评论...
验证码 换一张
取 消