How to Determine Default Libraries for an .OBJ Object FileLast reviewed: March 6, 1998Article ID: Q143072 |
The information in this article applies to:
- Microsoft Visual C++, 32-bit Edition, 2.0, 2.1, 2.2, 4.0, 5.0
SUMMARYIn 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. For additional information, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q128641 TITLE : The /Mx Compiler Options and the LIBC, LIBCMT, MSVCRT LibsYou 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 INFORMATIONTo 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):
DUMPBIN /RAWDATA /SECTION:.drectve MFCAPP.OBJ > OUTPUT.TXTIn the column to the right side of the output, you'll see the list of default libraries; the following is an excerpt from that column: -default|lib:mfc4 0.lib -d|efaultli b:mfcs40|.lib -de faultlib|:msvcrt. lib -def|aultlib: kernel32|.lib -de faultlib|:user32. lib From this excerpt, you can determine this object file will cause the linker to automatically search Mfc40.lib, Msvcrt.lib, Kernel32.lib, and User32.lib when building an executable file. As you can see, each library name is preceded with "-defaultlib:". You can use this procedure for multiple object files, and compare the output of each file. 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."
|
Additional query words:
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |