You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LIB creates standard libraries, import libraries, and export files you can use with [LINK](linker-options.md) when building a program. LIB runs from a command prompt.
11
+
LIB (lib.exe) creates standard libraries, import libraries, and export files you can use with [LINK](linker-options.md) when building a program. LIB runs from a command prompt.
12
12
13
13
You can use LIB in the following modes:
14
14
@@ -20,31 +20,31 @@ You can use LIB in the following modes:
20
20
21
21
These modes are mutually exclusive; you can use LIB in only one mode at a time.
22
22
23
-
## Lib Options
23
+
## LIB Options
24
24
25
25
The following table lists the options for lib.exe, with a link to more information.
26
26
27
27
|Option|Description|
28
28
|-|-|
29
-
|**/DEF**|Create an import library and an export file.<br/><br/>For more information see [Building an Import Library and Export File](building-an-import-library-and-export-file.md).|
30
-
|**/ERRORREPORT**| Send information to Microsoft about internal errors with lib.exe.<br/><br/>For more information see [Running LIB](running-lib.md).|
31
-
|**/EXPORT**| Exports a function from your program.<br/><br/>For more information see [Building an Import Library and Export File](building-an-import-library-and-export-file.md).|
32
-
|**/EXTRACT**| Create an object (.obj) file that contains a copy of a member of an existing library.<br/><br/>For more information see [Extracting a Library Member](extracting-a-library-member.md).|
33
-
|**/INCLUDE**| Adds a symbol to the symbol table.<br/><br/>For more information see [Building an Import Library and Export File](building-an-import-library-and-export-file.md).|
34
-
|**/LIBPATH**| Overrides the environment library path.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
29
+
|**/DEF**|Create an import library and an export file.<br/><br/>For more information, see [Building an Import Library and Export File](building-an-import-library-and-export-file.md).|
30
+
|**/ERRORREPORT**| Send information to Microsoft about internal errors with lib.exe.<br/><br/>For more information, see [Running LIB](running-lib.md).|
31
+
|**/EXPORT**| Exports a function from your program.<br/><br/>For more information, see [Building an Import Library and Export File](building-an-import-library-and-export-file.md).|
32
+
|**/EXTRACT**| Create an object (.obj) file that contains a copy of a member of an existing library.<br/><br/>For more information, see [Extracting a Library Member](extracting-a-library-member.md).|
33
+
|**/INCLUDE**| Adds a symbol to the symbol table.<br/><br/>For more information, see [Building an Import Library and Export File](building-an-import-library-and-export-file.md).|
34
+
|**/LIBPATH**| Overrides the environment library path.<br/><br/>For more information, see [Managing a Library](managing-a-library.md).|
35
35
|**/LINKREPRO**| Creates artifacts needed to reproduce a lib.exe crash or internal error.<br/><br/>For more information, see [Running LIB](running-lib.md).|
36
36
|**/LINKREPROTARGET**| Only generates the **/LINKREPRO** artifacts when lib.exe is used with a specified file.<br/><br/>For more information, see [Running LIB](running-lib.md).|
37
-
|**/LIST**| Displays information about the output library to standard output.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
38
-
|**/LTCG**| Causes the library to be built using link-time code generation.<br/><br/>For more information see [Running LIB](running-lib.md).|
39
-
|**/MACHINE**| Specifies the target platform for the program.<br/><br/>For more information see [Running LIB](running-lib.md).|
40
-
|**/NAME**| When building an import library, specifies the name of the DLL for which the import library is being built.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
41
-
|**/NODEFAULTLIB**| Removes one or more default libraries from the list of libraries it searches when resolving external references.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
42
-
|**/NOLOGO**| Suppresses display of the LIB copyright message and version number and prevents echoing of command files.<br/><br/>For more information see [Running LIB](running-lib.md).|
43
-
|**/OUT**| Overrides the default output filename.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
44
-
|**/REMOVE**| Omits an object from the output library.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
45
-
|**/SUBSYSTEM**| Tells the operating system how to run a program created by linking to the output library.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
46
-
|**/VERBOSE**| Displays details about the progress of the session, including names of the .obj files being added.<br/><br/>For more information see [Running LIB](running-lib.md).|
47
-
|**/WX**| Treat warnings as errors.<br/><br/>For more information see [Running LIB](running-lib.md).|
37
+
|**/LIST**| Displays information about the output library to standard output.<br/><br/>For more information, see [Managing a Library](managing-a-library.md).|
38
+
|**/LTCG**| Causes the library to be built using link-time code generation.<br/><br/>For more information, see [Running LIB](running-lib.md).|
39
+
|**/MACHINE**| Specifies the target platform for the program.<br/><br/>For more information, see [Running LIB](running-lib.md).|
40
+
|**/NAME**| When building an import library, specifies the name of the DLL for which the import library is being built.<br/><br/>For more information, see [Managing a Library](managing-a-library.md).|
41
+
|**/NODEFAULTLIB**| Removes one or more default libraries from the list of libraries it searches when resolving external references.<br/><br/>For more information, see [Managing a Library](managing-a-library.md).|
42
+
|**/NOLOGO**| Suppresses display of the LIB copyright message and version number and prevents echoing of command files.<br/><br/>For more information, see [Running LIB](running-lib.md).|
43
+
|**/OUT**| Overrides the default output filename.<br/><br/>For more information, see [Managing a Library](managing-a-library.md).|
44
+
|**/REMOVE**| Omits an object from the output library.<br/><br/>For more information, see [Managing a Library](managing-a-library.md).|
45
+
|**/SUBSYSTEM**| Tells the operating system how to run a program created by linking to the output library.<br/><br/>For more information, see [Managing a Library](managing-a-library.md).|
46
+
|**/VERBOSE**| Displays details about the progress of the session, including names of the .obj files being added.<br/><br/>For more information, see [Running LIB](running-lib.md).|
47
+
|**/WX**| Treat warnings as errors.<br/><br/>For more information, see [Running LIB](running-lib.md).|
Copy file name to clipboardExpand all lines: docs/build/reference/running-lib.md
+15-12Lines changed: 15 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,24 +14,21 @@ Various command-line options can be used to control LIB.
14
14
15
15
To run LIB, type the command `lib` followed by the options and file names for the task you are using LIB to perform. LIB also accepts command-line input in command files, which are described in the following section. LIB does not use an environment variable.
16
16
17
-
> [!NOTE]
18
-
> If you are accustomed to the LINK32.exe and LIB32.exe tools provided with the Microsoft Win32 Software Development Kit for Windows NT, you may have been using either the command `link32 -lib` or the command `lib32` for managing libraries and creating import libraries. Be sure to change your makefiles and batch files to use the `lib` command instead.
19
-
20
17
## LIB Command Files
21
18
22
19
You can pass command-line arguments to LIB in a command file using the following syntax:
23
20
24
-
> **LIB \@**<em>commandfile</em>
21
+
> **LIB \@**<em>command-file</em>
25
22
26
-
The file *commandfile* is a text file. No space or tab is allowed between the at sign (**\@**) and the file name. There is no default extension; you must specify the full file name, including any extension. Wildcards cannot be used. You can specify an absolute or relative path with the file name.
23
+
The file *command-file* is a text file. No spaces or tabs are allowed between the at sign (**\@**) and the file name. The *command-file* name has no default extension; you must specify the full file name, including any extension. Wildcards can't be used. You can specify an absolute or relative path with the file name.
27
24
28
-
In the command file, arguments can be separated by spaces or tabs, as they can on the command line; they can also be separated by newline characters. Use a semicolon (**;**) to mark a comment. LIB ignores all text from the semicolon to the end of the line.
25
+
In the command file, arguments can be separated by spaces or tabs, as they can on the command line. Arguments can also be separated by newline characters. Use a semicolon (**;**) to mark a comment. LIB ignores all text from the semicolon to the end of the line.
29
26
30
-
You can specify either all or part of the command line in a command file, and you can use more than one command file in a LIB command. LIB accepts the command-file input as if it were specified in that location on the command line. Command files cannot be nested. LIB echoes the contents of command files unless the /NOLOGO option is used.
27
+
You can specify either all or part of the command line in a command file, and you can use more than one command file in a LIB command. LIB accepts the command-file input as if it's specified in that location on the command line. Command files can't be nested. LIB echoes the contents of command files unless the **/NOLOGO** option is used.
31
28
32
29
## Using LIB Options
33
30
34
-
An option consists of an option specifier, which is either a dash (**-**) or a forward slash (**/**), followed by the name of the option. Option names cannot be abbreviated. Some options take an argument, specified after a colon (**:**). No spaces or tabs are allowed within an option specification. Use one or more spaces or tabs to separate option specifications on the command line. Option names and their keyword or file name arguments are not casesensitive, but identifiers used as arguments are casesensitive. LIB processes options in the order specified on the command line and in command files. If an option is repeated with different arguments, the last one to be processed takes precedence.
31
+
An option consists of an option specifier, which is either a dash (**-**) or a forward slash (**/**), followed by the name of the option. Option names can't be abbreviated. Some options take an argument, specified after a colon (**:**). No spaces or tabs are allowed within an option specification. Use one or more spaces or tabs to separate option specifications on the command line. Option names and their keyword or file name arguments aren't case-sensitive, but identifiers used as arguments are case-sensitive. LIB processes options in the order specified on the command line and in command files. If an option is repeated with different arguments, the last one to be processed takes precedence.
35
32
36
33
The following options apply to all modes of LIB:
37
34
@@ -41,22 +38,28 @@ If lib.exe fails at runtime, you can use **/ERRORREPORT** to send information to
41
38
42
39
For more information about **/ERRORREPORT**, see [/errorReport (Report Internal Compiler Errors)](errorreport-report-internal-compiler-errors.md).
43
40
41
+
::: moniker range=">=vs-2019"
42
+
44
43
> **/LINKREPRO:**_directory-path_\
45
44
> **/LINKREPROTARGET:**_filename_
46
45
47
46
To help Microsoft diagnose lib.exe crashes and internal errors, you can use the **/LINKREPRO** option. It works the same way as the [/LINKREPRO](linkrepro.md) linker option. The [/LINKREPROTARGET](linkreprotarget.md) option can be used with the **/LINKREPRO** option. It filters on a _filename_, to only generate repro artifacts when lib.exe is used on that file. For more information, see [How to report a problem with the Microsoft C++ toolset](../../overview/how-to-report-a-problem-with-the-visual-cpp-toolset.md).
48
47
48
+
The **/LINKREPRO** and **/LINKREPROTARGET** options are available starting in Visual Studio 2019 version 16.1.
49
+
50
+
::: moniker-end
51
+
49
52
> **/LTCG**
50
53
51
54
"LTCG" stands for *link-time code generation*. This feature requires cooperation between the compiler ([cl.exe](compiler-options.md)), LIB, and the linker ([LINK](linker-options.md)) in order to optimize code beyond what any component can do by itself.
52
55
53
-
For LIB, the **/LTCG** option specifies that the inputs from cl.exe include object files that were generated by using the [/GL](gl-whole-program-optimization.md) compiler option. If LIB encounters such inputs and **/LTCG**is not specified, it will restart with /LTCG enabled after displaying an informational message. In other words, it is not necessary to explicitly set this option, but it speeds up build performance to do so because LIB does not have to restart itself.
56
+
For LIB, the **/LTCG** option specifies that the inputs from cl.exe include object files that were generated by using the [/GL](gl-whole-program-optimization.md) compiler option. If LIB encounters such inputs and **/LTCG**isn't specified, it will restart with /LTCG enabled after displaying an informational message. In other words, it isn't necessary to explicitly set this option, but it speeds up build performance to do so because LIB doesn't have to restart itself.
54
57
55
-
In the build process, the output from LIB is sent to LINK. LINK has its own separate **/LTCG** option which is used to perform various optimizations, including whole-program optimization and profile-guided optimization (PGO) instrumentation. For more information about the LINK option, see [/LTCG](ltcg-link-time-code-generation.md).
58
+
In the build process, the output from LIB is sent to LINK. LINK has its own separate **/LTCG** option. It's used to perform various optimizations, including whole-program optimization and profile-guided optimization (PGO) instrumentation. For more information about the LINK option, see [/LTCG](ltcg-link-time-code-generation.md).
56
59
57
60
> **/MACHINE**
58
61
59
-
Specifies the target platform for the program. Usually, you do not need to specify /MACHINE. LIB infers the machine type from the .obj files. However, in some circumstances, LIB cannot determine the machine type and issues an error message. If such an error occurs, specify /MACHINE. In /EXTRACT mode, this option is for verification only. Use `lib /?` at the command line to see available machine types.
62
+
Specifies the target platform for the program. Usually, you don't need to specify **/MACHINE**. LIB infers the machine type from the .obj files. However, in some circumstances, LIB can't determine the machine type and issues an error message. If such an error occurs, specify **/MACHINE**. In **/EXTRACT** mode, this option is for verification only. Use `lib /?` at the command line to see available machine types.
60
63
61
64
> **/NOLOGO**
62
65
@@ -68,7 +71,7 @@ Displays details about the progress of the session, including names of the .obj
68
71
69
72
> **/WX**[**:NO**]
70
73
71
-
Treat warnings as errors. See [/WX (Treat Linker Warnings as Errors)](wx-treat-linker-warnings-as-errors.md) for more information.
74
+
Treat warnings as errors. For more information, see [/WX (Treat Linker Warnings as Errors)](wx-treat-linker-warnings-as-errors.md).
72
75
73
76
Other options apply only to specific modes of LIB. These options are discussed in the sections describing each mode.
0 commit comments