Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I see a MSVCR90 dependency even though I set the /MT option?

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?

like image 377
Mason Wheeler Avatar asked Oct 10 '22 17:10

Mason Wheeler


1 Answers

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.

like image 176
Hans Passant Avatar answered Oct 14 '22 02:10

Hans Passant