Article ID: 143072 - Last Review: January 9, 2006 - Revision: 5.0 How to determine default libraries for an .obj object file in Visual C++This article was previously published under Q143072 Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003
support both the managed code model that is provided by the Microsoft .NET
Framework and the unmanaged native Microsoft Windows code model. The
information in this article applies only to unmanaged Visual C++
code. Microsoft Visual C++ 2005 supports both the managed code model that
is provided by the Microsoft .NET Framework and the unmanaged native Microsoft
Windows code model. SUMMARY In Visual C++, default libraries can be linked to
automatically. This is done for the C run-time libraries. The compiler writes a
default C run-time library name in the object (.obj) files it creates. The
library name depends on the compiler options you use. You can also specify default libraries by the using the #pragma comment() compiler directive. The Microsoft Foundation Class (MFC) header files do this. Writing a default library name in an object file in this manner saves you from having to specify the library on the linker command line. However, sometimes it is necessary to determine which libraries an object file links to by default. MORE INFORMATION To see which libraries an object file will use by default,
you can use the Dumpbin.exe utility in a console session. For example, to find
out which libraries Mfcapp.obj will cause the linker to search automatically,
you would use the following code (this example pipes the output to a file): -default|lib:mfc4 0.lib -d|efaultli b:mfcs40|.lib -de faultlib|:msvcrt. lib -def|aultlib: kernel32|.lib -de faultlib|:user32. lib One reason you may need to determine which default library names are in an object file is to troubleshoot the LNK2005 error, "symbol multiply defined." APPLIES TO
| Article Translations
|

Back to the top
