5
votes

I'm building a DLL in Visual C++ 2008, and I want to have the runtime statically linked into the DLL. So I went into the project options and set Runtime Library to Multi-threaded (/MT). This has always worked for other projects in the past. But when I build this one, I still end up with Dependency Walker showing MSVCR90.dll in the list.

Anyone know what could cause that?

1
Clearly the EXE that loads your DLL was not built with the same option. Or another DLL that got loaded, it takes only one.Hans Passant
@Hank: Not applicable here. I'm looking at it in Dependency Walker, and it shows at the top level of the tree, not under another loaded DLL.Mason Wheeler
What export(s) in MSVCR90 is your DLL dependent on?Michael Burr

1 Answers

4
votes

Project + Properties, Linker, Command Line. Add the /verbose option. Build + Rebuild. The Output window shows you the linker searching for symbols. Watch out for msvcrt.lib, that's the one that pulls in the dependency on msvcr90.dll

The typical cause is linking a .lib that has one or more .obj files that were compiled with /MD. A dependency on msvcrt.lib gets injected with the #pragma comment(lib, msvcrt.lib) directive. That tells the linker to search msvcrt.lib without you explicitly specifying it as a dependency in Linker, Input, Additional Dependencies.