|
1 | 1 | --- |
2 | | -title: "/Fo (Object File Name)" |
3 | | -ms.date: "11/04/2016" |
| 2 | +title: "/Fo (Object file name)" |
| 3 | +description: "Reference guide to the Microsoft C++ /Fo (Object file name) compiler option in Visual Studio." |
| 4 | +ms.date: "04/20/2020" |
4 | 5 | f1_keywords: ["/Fo", "VC.Project.VCCLCompilerTool.ObjectFile", "VC.Project.VCCLWCECompilerTool.ObjectFile"] |
5 | 6 | helpviewer_keywords: ["Fo compiler option [C++]", "object files, naming", "/Fo compiler option [C++]", "-Fo compiler option [C++]"] |
6 | 7 | ms.assetid: 0e6d593e-4e7f-4990-9e6e-92e1dcbcf6e6 |
7 | 8 | --- |
8 | 9 | # /Fo (Object File Name) |
9 | 10 |
|
10 | | -Specifies an object (.obj) file name or directory to be used instead of the default. |
| 11 | +Specifies an object (*`.obj`*) file name or directory to be used instead of the default. |
11 | 12 |
|
12 | 13 | ## Syntax |
13 | 14 |
|
14 | | -``` |
15 | | -/Fopathname |
16 | | -``` |
| 15 | +> **`/Fo`**_pathname_ |
17 | 16 |
|
18 | 17 | ## Remarks |
19 | 18 |
|
20 | | -If you do not use this option, the object file uses the base name of the source file and the .obj extension. You can use any name and extension you want, but the recommended convention is to use .obj. |
| 19 | +You can use the **`/Fo`** compiler option to set an output directory for all the object files generated by the CL compiler command. Or, you can use it to rename a single object file. |
21 | 20 |
|
22 | | -### To set this compiler option in the Visual Studio development environment |
| 21 | +By default, the object files generated by the compiler are placed in the current directory. They're given the base name of the source file and a *`.obj`* extension. |
23 | 22 |
|
24 | | -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). |
| 23 | +To use the **`/Fo`** option to rename an object file, specify the output filename as the *pathname* argument. When you rename an object file, you can use any name and extension you want, but the recommended convention is to use *`.obj`*. The compiler generates command line error D8036 if you specify a filename to **`/Fo`** when you've specified more than one source file to compile. |
25 | 24 |
|
26 | | -1. Click the **C/C++** folder. |
| 25 | +To use the **`/Fo`** option to set an output directory for all object files created by the CL command, specify the directory as the *pathname* argument. A directory is indicated by a trailing slash in the *pathname* argument. The specified directory must exist; it's not created automatically. |
27 | 26 |
|
28 | | -1. Click the **Output Files** property page. |
| 27 | +## Example |
29 | 28 |
|
30 | | -1. Modify the **Object File Name** property. In the development environment, the object file must have an extension of .obj. |
| 29 | +The following command line creates an object file named *sample.obj* in an existing directory, *\\intermediate*, on drive D. |
31 | 30 |
|
32 | | -### To set this compiler option programmatically |
| 31 | +```cmd |
| 32 | +CL /Fo"D:\intermediate\" /EHsc /c sample.cpp |
| 33 | +``` |
33 | 34 |
|
34 | | -- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.ObjectFile%2A>. |
| 35 | +## Set the option in Visual Studio or programmatically |
35 | 36 |
|
36 | | -## Example |
| 37 | +### To set this compiler option in the Visual Studio development environment |
37 | 38 |
|
38 | | -The following command line creates an object file named THIS.obj in an existing directory, \OBJECT, on drive B. |
| 39 | +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). |
39 | 40 |
|
40 | | -``` |
41 | | -CL /FoB:\OBJECT\ THIS.C |
42 | | -``` |
| 41 | +1. Select the **Configuration Properties** > **C/C++** > **Output Files** property page. |
| 42 | + |
| 43 | +1. Modify the **Object File Name** property to set the output directory. In the IDE, the object file must have an extension of *`.obj`*. |
| 44 | + |
| 45 | +### To set this compiler option programmatically |
| 46 | + |
| 47 | +- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.ObjectFile%2A>. |
43 | 48 |
|
44 | 49 | ## See also |
45 | 50 |
|
|
0 commit comments