Skip to content

Add cmd language for CL and LINK invocations #5568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions docs/build/reference/c-compile-without-linking.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: /c (Compile Without Linking)"
title: "/c (Compile Without Linking)"
ms.date: "11/04/2016"
description: "Learn more about: /c (Compile Without Linking)"
ms.date: 11/04/2016
f1_keywords: ["/c"]
helpviewer_keywords: ["suppress link", "cl.exe compiler, compiling without linking", "-c compiler option [C++]", "c compiler option [C++]", "/c compiler option [C++]"]
ms.assetid: 8017fc3d-e5dd-4668-a1f7-3120daa95d20
---
# /c (Compile Without Linking)

Expand Down Expand Up @@ -34,13 +33,13 @@ Any internal project created in the development environment uses the **/c** opti

The following command line creates the object files FIRST.obj and SECOND.obj. THIRD.obj is ignored.

```
```cmd
CL /c FIRST.C SECOND.C THIRD.OBJ
```

To create an executable file, you must invoke LINK:

```
```cmd
LINK first.obj second.obj third.obj /OUT:filename.exe
```

Expand Down
7 changes: 3 additions & 4 deletions docs/build/reference/cl-invokes-the-linker.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
description: "Learn more about: CL Invokes the Linker"
title: "CL Invokes the Linker"
ms.date: "11/04/2016"
description: "Learn more about: CL Invokes the Linker"
ms.date: 11/04/2016
helpviewer_keywords: ["compiling source code [C++], without linking", "invoking linker from the compiler", "LINK tool [C++], invoking from CL compiler", "cl.exe compiler [C++], compiling without linking", "cl.exe compiler [C++], controlling linker"]
ms.assetid: eae47ef7-09eb-40c9-b318-7c714cd452fc
---
# CL Invokes the Linker

Expand All @@ -30,7 +29,7 @@ Assume that you are compiling three C source files: MAIN.c, MOD1.c, and MOD2.c.

To build this program, compile with the following command line:

```
```cmd
CL MAIN.c MOD1.C MOD2.C MYGRAPH.lib
```

Expand Down
7 changes: 3 additions & 4 deletions docs/build/reference/compiler-command-line-syntax.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
---
description: "Learn more about: Compiler Command-Line Syntax"
title: "MSVC Compiler Command-Line Syntax"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Command-Line Syntax"
ms.date: 11/04/2016
helpviewer_keywords: ["syntax, CL compiler command line", "cl.exe compiler, command-line syntax"]
ms.assetid: acba2c1c-0803-4a3a-af25-63e849b930a2
---
# Compiler Command-Line Syntax

The CL command line uses the following syntax:

```
```cmd
CL [option...] file... [option | file]... [lib...] [@command-file] [/link link-opt...]
```

Expand Down
9 changes: 4 additions & 5 deletions docs/build/reference/e-preprocess-to-stdout.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: /E (Preprocess to stdout)"
title: "/E (Preprocess to stdout)"
ms.date: "11/04/2016"
description: "Learn more about: /E (Preprocess to stdout)"
ms.date: 11/04/2016
f1_keywords: ["/e"]
helpviewer_keywords: ["-E compiler option [C++]", "/E compiler option [C++]", "preprocessor output, copy to stdout", "preprocessor output"]
ms.assetid: ddbb1725-d950-4978-ab2f-30a5cd7b778c
---
# /E (Preprocess to stdout)

Expand Down Expand Up @@ -44,7 +43,7 @@ m(int)main( )

However, if you compile with:

```
```cmd
cl -E test.cpp > test2.cpp
```

Expand All @@ -66,7 +65,7 @@ cl -E test.cpp > test2.cpp

The following command line preprocesses `ADD.C`, preserves comments, adds `#line` directives, and displays the result on the standard output device:

```
```cmd
CL /E /C ADD.C
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: /EP (Preprocess to stdout Without #line Directives)"
title: "/EP (Preprocess to stdout Without #line Directives)"
ms.date: "11/04/2016"
description: "Learn more about: /EP (Preprocess to stdout Without #line Directives)"
ms.date: 11/04/2016
f1_keywords: ["/ep", "VC.Project.VCCLCompilerTool.GeneratePreprocessedFileNoLines"]
helpviewer_keywords: ["copy preprocessor output to stdout", "preprocessor output, copy to stdout", "-EP compiler option [C++]", "EP compiler option [C++]", "/EP compiler option [C++]"]
ms.assetid: 6ec411ae-e33d-4ef5-956e-0054635eabea
---
# /EP (Preprocess to stdout Without #line Directives)

Expand Down Expand Up @@ -46,7 +45,7 @@ You cannot use precompiled headers with the **/EP** option.

The following command line preprocesses file `ADD.C`, preserves comments, and displays the result on the standard output device:

```
```cmd
CL /EP /C ADD.C
```

Expand Down
7 changes: 3 additions & 4 deletions docs/build/reference/fd-program-database-file-name.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: /Fd (Program Database File Name)"
title: "/Fd (Program Database File Name)"
ms.date: "11/04/2016"
description: "Learn more about: /Fd (Program Database File Name)"
ms.date: 11/04/2016
f1_keywords: ["/FD", "VC.Project.VCCLWCECompilerTool.ProgramDataBaseFileName", "VC.Project.VCCLCompilerTool.ProgramDataBaseFileName"]
helpviewer_keywords: ["/FD compiler option [C++]", "program database file name [C++]", "-FD compiler option [C++]", "PDB files, creating", "program database compiler option [C++]", ".pdb files, creating", "FD compiler option [C++]"]
ms.assetid: 3977a9ed-f0ac-45df-bf06-01cedd2ba85a
---
# /Fd (Program Database File Name)

Expand Down Expand Up @@ -42,7 +41,7 @@ This option also names the state (.idb) file used for minimal rebuild and increm

This command line creates a .pdb file named PROG.pdb and an .idb file named PROG.idb:

```
```cmd
CL /DDEBUG /Zi /FdPROG.PDB PROG.CPP
```

Expand Down
9 changes: 4 additions & 5 deletions docs/build/reference/fe-name-exe-file.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: /Fe (Name EXE File)"
title: "/Fe (Name EXE File)"
ms.date: "11/04/2016"
description: "Learn more about: /Fe (Name EXE File)"
ms.date: 11/04/2016
f1_keywords: ["/fe"]
helpviewer_keywords: ["-Fe compiler option [C++]", "executable files, renaming", "rename file compiler option [C++]", "/Fe compiler option [C++]", "Fe compiler option [C++]"]
ms.assetid: 49f594fd-5e94-45fe-a1bf-7c9f2abb6437
---
# /Fe (Name EXE File)

Expand Down Expand Up @@ -44,13 +43,13 @@ If you specify the [/c (Compile Without Linking)](c-compile-without-linking.md)

The following command line compiles and links all C source files in the current directory. The resulting executable file is named PROCESS.exe and is created in the directory "C:\Users\User Name\repos\My Project\bin".

```
```cmd
CL /Fe"C:\Users\User Name\repos\My Project\bin\PROCESS" *.C
```

The following command line creates an executable file in `C:\BIN` with the same base name as the first source file in the current directory:

```
```cmd
CL /FeC:\BIN\ *.C
```

Expand Down
7 changes: 3 additions & 4 deletions docs/build/reference/p-preprocess-to-a-file.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: /P (Preprocess to a File)"
title: "/P (Preprocess to a File)"
ms.date: "11/04/2016"
description: "Learn more about: /P (Preprocess to a File)"
ms.date: 11/04/2016
f1_keywords: ["VC.Project.VCCLCompilerTool.GeneratePreprocessedFile", "/p", "VC.Project.VCCLWCECompilerTool.GeneratePreprocessedFile"]
helpviewer_keywords: ["/P compiler option [C++]", "-P compiler option [C++]", "P compiler option [C++]", "output files, preprocessor", "preprocessing output files"]
ms.assetid: 123ee54f-8219-4a6f-9876-4227023d83fc
---
# /P (Preprocess to a File)

Expand Down Expand Up @@ -40,7 +39,7 @@ The **/P** option suppresses compilation. It does not produce an .obj file, even

The following command line preprocesses `ADD.C`, preserves comments, adds `#line` directives, and writes the result to a file, `ADD.I`:

```
```cmd
CL /P /C ADD.C
```

Expand Down
7 changes: 3 additions & 4 deletions docs/build/reference/specifying-the-pathname.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
description: "Learn more about: Specifying the Pathname"
title: "Specifying the Pathname"
ms.date: "11/04/2016"
description: "Learn more about: Specifying the Pathname"
ms.date: 11/04/2016
helpviewer_keywords: ["names [C++], compiler output files", "cl.exe compiler, output files", "output files, specifying pathnames"]
ms.assetid: 7a6595ce-3383-44ae-957a-466bfa29c343
---
# Specifying the Pathname

Expand All @@ -24,7 +23,7 @@ Alternatively, the *pathname* argument can be a device name (AUX, CON, PRN, or N

The following command line sends a mapfile to the printer:

```
```cmd
CL /FmPRN HELLO.CPP
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: /Yd (Place Debug Information in Object File)"
title: "/Yd (Place Debug Information in Object File)"
ms.date: "11/04/2016"
description: "Learn more about: /Yd (Place Debug Information in Object File)"
ms.date: 11/04/2016
f1_keywords: ["/yd"]
helpviewer_keywords: ["/Yd compiler option [C++]", "-Yd compiler option [C++]", "debugging [C++], debug information files", "Yd compiler option [C++]"]
ms.assetid: c5a699fe-65ce-461e-964c-7f5eb2a8320a
---
# /Yd (Place Debug Information in Object File)

Expand Down Expand Up @@ -55,13 +54,13 @@ Suppose you have two base files, F.cpp and G.cpp, each containing these **#inclu

The following command creates the precompiled header file ETC.pch and the object file F.obj:

```
```cmd
CL /YcETC.H /Z7 F.CPP
```

The object file F.obj includes type and symbol information for WINDOWS.h and ETC.h (and any other header files they include). Now you can use the precompiled header ETC.pch to compile the source file G.cpp:

```
```cmd
CL /YuETC.H /Z7 G.CPP
```

Expand Down
9 changes: 4 additions & 5 deletions docs/error-messages/tool-errors/command-line-warning-d9027.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Command-Line Warning D9027"
title: "Command-Line Warning D9027"
ms.date: "11/04/2016"
description: "Learn more about: Command-Line Warning D9027"
ms.date: 11/04/2016
f1_keywords: ["D9027"]
helpviewer_keywords: ["D9027"]
ms.assetid: 2a29edc5-5649-48f2-9058-2057c747284c
---
# Command-Line Warning D9027

Expand All @@ -14,12 +13,12 @@ CL.exe ignored the input source file.

This warning can be caused by a space between the /Fo option and an output filename on a command line with the /c option. For example:

```
```cmd
cl /c /Fo output.obj input.c
```

Because there is a space between /Fo and `output.obj`, CL.exe takes `output.obj` as the name of the input file. To fix the problem, remove the space:

```
```cmd
cl /c /Fooutput.obj input.c
```
7 changes: 3 additions & 4 deletions docs/error-messages/tool-errors/linker-tools-error-lnk2011.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Linker Tools Error LNK2011"
title: "Linker Tools Error LNK2011"
ms.date: "11/04/2016"
description: "Learn more about: Linker Tools Error LNK2011"
ms.date: 11/04/2016
f1_keywords: ["LNK2011"]
helpviewer_keywords: ["LNK2011"]
ms.assetid: 04991ef5-49d5-46c7-8eee-a9d1d3fc541e
---
# Linker Tools Error LNK2011

Expand All @@ -14,7 +13,7 @@ If you use precompiled headers, LINK requires that all of the object files creat

For example, if you compile a file called STUB.cpp to create a precompiled header for use with other source files, you must link with STUB.obj or you will get this error. In the following command lines, line one is used to create a precompiled header, COMMON.pch, which is used with PROG1.cpp and PROG2.cpp in lines two and three. The file STUB.cpp contains only `#include` lines (the same `#include` lines as in PROG1.cpp and PROG2.cpp) and is used only to generate precompiled headers. In the last line, STUB.obj must be linked in to avoid LNK2011.

```
```cmd
cl /c /Yccommon.h stub.cpp
cl /c /Yucommon.h prog1.cpp
cl /c /Yucommon.h prog2.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Linker Tools Warning LNK4105"
title: "Linker Tools Warning LNK4105"
ms.date: "11/04/2016"
description: "Learn more about: Linker Tools Warning LNK4105"
ms.date: 11/04/2016
f1_keywords: ["LNK4105"]
helpviewer_keywords: ["LNK4105"]
ms.assetid: 6c7bebf4-4ea6-4533-a6ed-e563d43abbd7
---
# Linker Tools Warning LNK4105

Expand All @@ -16,7 +15,7 @@ If you do not need to override the existing environmental library settings, remo

## Example

```
```cmd
link /libpath:c:\filepath\lib bar.obj
```

Expand Down