Search code examples
c++linkerdependencies

C++ library is in AdditionalDependencies but is not listed by dumpbin nor dependencywalker


I have a C++ project in VS, producing a dll, let's call it "A.dll". Under A.dll >> Linker >> AdditionalDependencies, there is an entry for a library "B.lib". When I put "A.dll" through dumpbin or depencencywalker, the library "B.lib" is not listed.

I've tried to remove "B.lib" from AdditionalDependencies, but it causes a liker error with A.dll. This is confusing. I'd expect that library B.lib (which is obviously required by A.dll) should be embedded into A.dll and be visible via "dumpbin /dependends" or similar tools.

I am new to C++ and trying to understand how it is possible. Maybe somebody could explain.


Solution

  • At least at first glance, this sounds like B.lib is a static library. If so, that means whatever's needed from B.lib is replicated into the executable (A.dll) at link time. At run time, there's no longer any dependency on B.lib.

    The dependencies that show up with something like Dependency Walker are dynamic link libraries (DLLs). With a DLL, you'll have a .lib file, but all it contains are basically stubs of functions--enough information to tell the linker how to create a record in your executable to find and use the appropriate function from the DLL. Then at run-time, the user needs a copy of the appropriate DLL to actually use the function. When you start the executable, the Windows loader not only loads your executable file into memory, but also loads all the DLLs it needs.