.LIB Files as Linker Input

OverviewFAQDetailsLinker Options

LINK accepts COFF standard libraries and COFF import libraries, both of which usually have the extension .LIB. Standard libraries contain objects and are created by the LIB tool. Import libraries contain information about exports in other programs and are created either by LINK when it builds a program that contains exports or by the LIB tool. For information on using LIB to create standard or import libraries, see LIB Reference. For details on using LINK to create an import library, see the /DLL option.

A library is specified to LINK as either a file name argument or a default library. LINK resolves external references by searching first in libraries specified on the command line, then in default libraries specified with the /DEFAULTLIB option, and then in default libraries named in .OBJ files. If a path is specified with the library name, LINK looks for the library in that directory. If no path is specified, LINK looks first in the directory that LINK is running from, and then in any directories specified in the LIB environment variable.

LINK cannot link a library of 32-bit OMF objects created by the 16-bit version of LIB. To use an OMF library, you must first use the 16-bit LIB (not provided in Visual C++ for Windows NT) to extract the objects. You can then either link the OMF objects or use the 32-bit LIB to convert them to COFF and put them into a library. You can also use the EDITBIN.EXE tool to convert an OMF object to COFF.