Skip to content

Commit 59aeb70

Browse files
Merge pull request #2363 from corob-msft/cr-linkrepro
Add /LINKREPRO and /LINKREPROTARGET linker options
2 parents 2fee96c + 8874761 commit 59aeb70

7 files changed

Lines changed: 167 additions & 45 deletions

File tree

docs/build/reference/linker-options.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
2-
title: "MSVC Linker Options"
3-
ms.date: "08/20/2018"
2+
title: "MSVC Linker options"
3+
description: A list of the options supported by the Microsoft LINK linker.
4+
ms.date: "09/24/2019"
45
f1_keywords: ["link"]
56
helpviewer_keywords: ["linker [C++]", "linker [C++], options listed", "libraries [C++], linking to COFF", "LINK tool [C++], linker options"]
67
ms.assetid: c1d51b8a-bd23-416d-81e4-900e02b2c129
78
---
8-
# Linker Options
9+
# Linker options
910

1011
LINK.exe links Common Object File Format (COFF) object files and libraries to create an executable (.exe) file or a dynamic-link library (DLL).
1112

@@ -23,6 +24,8 @@ On the command line, linker options are not case-sensitive; for example, /base a
2324

2425
You can use the [comment](../../preprocessor/comment-c-cpp.md) pragma to specify some linker options.
2526

27+
## Linker options listed alphabetically
28+
2629
|Option|Purpose|
2730
|------------|-------------|
2831
|[@](at-specify-a-linker-response-file.md)|Specifies a response file.|
@@ -73,6 +76,8 @@ You can use the [comment](../../preprocessor/comment-c-cpp.md) pragma to specify
7376
|[/KEYFILE](keyfile-specify-key-or-key-pair-to-sign-an-assembly.md)|Specifies a key or key pair to sign an assembly.|
7477
|[/LARGEADDRESSAWARE](largeaddressaware-handle-large-addresses.md)|Tells the compiler that the application supports addresses larger than two gigabytes|
7578
|[/LIBPATH](libpath-additional-libpath.md)|Specifies a path to search before the environmental library path.|
79+
|[/LINKREPRO](linkrepro.md)|Specifies a path to generate link repro artifacts in.|
80+
|[/LINKREPROTARGET](linkreprotarget.md)|Generates a link repro only when producing the specified target.|
7681
|[/LTCG](ltcg-link-time-code-generation.md)|Specifies link-time code generation.|
7782
|[/MACHINE](machine-specify-target-platform.md)|Specifies the target platform.|
7883
|[/MANIFEST](manifest-create-side-by-side-assembly-manifest.md)|Creates a side-by-side manifest file and optionally embeds it in the binary.|
@@ -125,5 +130,5 @@ For more information, see [Compiler-Controlled LINK Options](compiler-controlled
125130

126131
## See also
127132

128-
[C/C++ Building Reference](c-cpp-building-reference.md)<br/>
133+
[C/C++ Building Reference](c-cpp-building-reference.md)\
129134
[MSVC linker reference](linking.md)

docs/build/reference/linkrepro.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: "/LINKREPRO (Link repro directory name)"
3+
description: Linker or library tool option to set the directory for a link repro.
4+
ms.date: "09/24/2019"
5+
f1_keywords: ["/LINKREPRO"]
6+
helpviewer_keywords: ["LINKREPRO linker option", "/LINKREPRO linker option", "-LINKREPRO linker option", "linker repro reporting"]
7+
---
8+
# /LINKREPRO (Link repro directory name)
9+
10+
Tells the linker or library tool to generate a link repro in a specified directory.
11+
12+
## Syntax
13+
14+
> **/LINKREPRO:**_directory-name_
15+
16+
### Arguments
17+
18+
**/LINKREPRO:**_directory-name_\
19+
The user-specified directory to store the link repro in. Directory names that include spaces must be enclosed in double quotes.
20+
21+
## Remarks
22+
23+
The **/LINKREPRO** option is used to create a *link repro*. It's a set of build artifacts that allow Microsoft to reproduce a problem that occurs at link time, or during library operations. It's useful for problems such as a backend crash involving Link-Time Code Generation (LTCG), an LNK1000 linker error, or a linker crash. The tool produces a link repro when you specify the **/LINKREPRO** linker option, or when you set the `link_repro` environment variable in your command-line build environment. For more information, see the [Link repros](../../overview/how-to-report-a-problem-with-the-visual-cpp-toolset.md#link-repros) section of [How to report a problem with the Microsoft C++ toolset](../../overview/how-to-report-a-problem-with-the-visual-cpp-toolset.md).
24+
25+
Both the **/LINKREPRO** linker option and the `link_repro` environment variable require you to specify an output directory for the link repro. On the command line or in the IDE, specify the directory by using a **/LINKREPRO:**_directory-name_ option. The _directory-name_ you specify may be an absolute or relative path, but the directory must exist. The command-line option overrides any directory value set in the `link_repro` environment variable.
26+
27+
For information on how to limit link repro generation to a specific target file name, see the [/LINKREPROTARGET](linkreprotarget.md) option. This option can be used to specify a specific target to generate a link repro for. It's useful in complex builds that invoke the linker or library tool more than once.
28+
29+
### To set this linker option in the Visual Studio development environment
30+
31+
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
32+
33+
1. Select the **Configuration Properties** > **Linker** > **Command Line** property page.
34+
35+
1. Enter the **/LINKREPRO:**_directory-name_ option in the **Additional Options** box. The _directory-name_ value you specify must exist. Choose **OK** to apply the change.
36+
37+
Once you've generated the link repro, open this property page again to remove the **/LINKREPRO** option from your builds.
38+
39+
### To set this linker option programmatically
40+
41+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool.AdditionalOptions%2A>.
42+
43+
## See also
44+
45+
[MSVC linker reference](linking.md)\
46+
[MSVC linker options](linker-options.md)\
47+
[/LINKREPROTARGET](linkreprotarget.md)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: "/LINKREPROTARGET (Link repro file name)"
3+
description: Linker or library tool option to set a target file name for a link repro.
4+
ms.date: "09/24/2019"
5+
f1_keywords: ["/LINKREPROTARGET"]
6+
helpviewer_keywords: ["LINKREPROTARGET linker option", "/LINKREPROTARGET linker option", "-LINKREPROTARGET linker option", "linker repro reporting"]
7+
---
8+
# /LINKREPROTARGET (Link repro file name)
9+
10+
Tells the linker or library tool to generate a link repro only when the target has the specified file name.
11+
12+
## Syntax
13+
14+
> **/LINKREPROTARGET:**_file-name_
15+
16+
### Arguments
17+
18+
**/LINKREPROTARGET:**_file-name_\
19+
The target file name to filter on. A link repro is only generated when the named file is the output target. File names that include spaces must be enclosed in double quotes. The file name should include the base name and the extension, but not the path.
20+
21+
## Remarks
22+
23+
The **/LINKREPROTARGET** option is used to specify a target file name to generate a *link repro* for. A link repro is a set of build artifacts that allow Microsoft to reproduce a problem that occurs at link time, or during library operations. The linker or library tool produces a link repro when you specify the [/LINKREPRO](linkrepro.md) option, or when you set the `link_repro` environment variable in your command-line build environment.
24+
25+
The **/LINKREPROTARGET** option is useful in complex builds that invoke the linker or library tool more than once. It lets you specify a specific target for the link repro, such as *problem.dll*. It lets you generate the link repro only when the tool produces a specific file.
26+
27+
For more information about how and when to create a link repro, see the [Link repros](../../overview/how-to-report-a-problem-with-the-visual-cpp-toolset.md#link-repros) section of [How to report a problem with the Microsoft C++ toolset](../../overview/how-to-report-a-problem-with-the-visual-cpp-toolset.md).
28+
29+
The **/LINKREPRO** and [/OUT](out-output-file-name.md) options must be set for the **/LINKREPROTARGET** option to have any effect.
30+
31+
### To set this linker option in the Visual Studio development environment
32+
33+
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
34+
35+
1. Select the **Configuration Properties** > **Linker** > **Command Line** property page.
36+
37+
1. Enter the **/LINKREPROTARGET:**_file-name_ option in the **Additional Options** box. Choose **OK** to apply the change.
38+
39+
### To set this linker option programmatically
40+
41+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool.AdditionalOptions%2A>.
42+
43+
## See also
44+
45+
[MSVC linker reference](linking.md)\
46+
[MSVC linker options](linker-options.md)\
47+
[/LINKREPRO](linkrepro.md)

docs/build/reference/overview-of-lib.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
22
title: "Overview of LIB"
3-
ms.date: "11/04/2016"
3+
description: Overview of the use and options of the library tool, lib.exe.
4+
ms.date: "09/25/2019"
45
f1_keywords: ["Lib"]
56
helpviewer_keywords: ["LIB [C++], modes"]
67
ms.assetid: e997d423-f574-434f-8b56-25585d137ee0
78
---
89
# Overview of LIB
910

10-
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.
1112

1213
You can use LIB in the following modes:
1314

@@ -19,29 +20,31 @@ You can use LIB in the following modes:
1920

2021
These modes are mutually exclusive; you can use LIB in only one mode at a time.
2122

22-
## Lib Options
23+
## LIB options
2324

2425
The following table lists the options for lib.exe, with a link to more information.
2526

2627
|Option|Description|
2728
|-|-|
28-
|**/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).|
29-
|**/ERRORREPORT**| Send information to Microsoft about internal errors with lib.exe.<br/><br/>For more information see [Running LIB](running-lib.md).|
30-
|**/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).|
31-
|**/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).|
32-
|**/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).|
33-
|**/LIBPATH**| Overrides the environment library path.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
34-
|**/LIST**| Displays information about the output library to standard output.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
35-
|**/LTCG**| Causes the library to be built using link-time code generation.<br/><br/>For more information see [Running LIB](running-lib.md).|
36-
|**/MACHINE**| Specifies the target platform for the program.<br/><br/>For more information see [Running LIB](running-lib.md).|
37-
|**/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).|
38-
|**/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).|
39-
|**/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).|
40-
|**/OUT**| Overrides the default output filename.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
41-
|**/REMOVE**| Omits an object from the output library.<br/><br/>For more information see [Managing a Library](managing-a-library.md).|
42-
|**/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).|
43-
|**/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).|
44-
|**/WX**| Treat warnings as errors.<br/><br/>For more information see [Running LIB](running-lib.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+
|**/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+
|**/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).|
4548

4649
## See also
4750

0 commit comments

Comments
 (0)