/DEBUG (Generate Debug Info)

 

The latest version of this topic can be found at -DEBUG (Generate Debug Info).

DEBUG[:{FASTLINK|FULL|NONE}]

  
## Remarks  

The **/DEBUG** option creates debugging information for the .exe file or DLL.    
  
The linker puts the debugging information into a program database (PDB) file. It updates the PDB during subsequent builds of the program.  
  
An executable (.exe file or DLL) created for debugging contains the name and path of the corresponding PDB. The debugger reads the embedded name and uses the PDB when you debug the program. The linker uses the base name of the program and the extension .pdb to name the program database, and embeds the path where it was created. To override this default, set [/PDB](../Topic/-PDB%20\(Use%20Program%20Database\).md) and specify a different file name.  

The **/DEBUG:FULL** option is the linker default for debug builds. This option is set when you specify /DEBUG with no additional options. This option moves all private symbol information from individual compilation products (object files and libraries) into a single PDB, and can be the most time-consuming part of the link. However, the full PDB can be used to debug the executable when no other build products are available, such as when the executable is deployed.

The **/DEBUG:FASTLINK** option leaves private symbol information in the individual compilation products used to build the executable. It generates a limited PDB that indexes into the debug information in the object files and libraries (and any associated PDB files) used to build the executable instead of making a full copy. This option can link from two to four times as fast as full PDB generation, and is recommended when you are debugging locally and have the build products available. This limited PDB can't be used for debugging when the required build products are not available, such as when the executable is deployed on another computer.

The **/DEBUG:NONE** option does not generate a PDB, and is the linker default for release builds.
  
The compiler's [C7 Compatible](../Topic/-Z7,%20-Zi,%20-ZI%20\(Debug%20Information%20Format\).md) (/Z7) option causes the compiler to leave the debugging information in the .obj files. You can also use the [Program Database](../Topic/-Z7,%20-Zi,%20-ZI%20\(Debug%20Information%20Format\).md) (/Zi) compiler option to store the debugging information in a PDB for the .obj file. The linker looks for the object's PDB first in the absolute path written in the .obj file, and then in the directory that contains the .obj file. You cannot specify an object's PDB file name or location to the linker.  
  
[/INCREMENTAL](../Topic/-INCREMENTAL%20\(Link%20Incrementally\).md) is implied when /DEBUG is specified.  
  
/DEBUG changes the defaults for the [/OPT](../Topic/-OPT%20\(Optimizations\).md) option from REF to NOREF and from ICF to NOICF, so if you want the original defaults, you must explicitly specify /OPT:REF or /OPT:ICF.  
  
It is not possible to create an .exe or .dll that contains debug information. Debug information is always placed in a .obj or .pdb file.  
  
### To set this linker option in the Visual Studio development environment  
  
1.  Open the project's **Property Pages** dialog box. For details, see [Setting Visual C++ Project Properties](../Topic/Working%20with%20Project%20Properties.md).  
  
2.  Click the **Linker** folder.  
  
3.  Click the **Debugging** property page.  
  
4.  Modify the **Generate Debug Info** property.  
  
### To set this linker option programmatically  
  
1.  See [GenerateDebugInformation](assetId:///P:Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool.GenerateDebugInformation?qualifyHint=False&autoUpgrade=True).  
  
## See Also  
 [Setting Linker Options](../Topic/Setting%20Linker%20Options.md)   
 [Linker Options](../Topic/Linker%20Options.md)