Linker Options

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

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

The following table lists options for LINK.exe. For more information about LINK, see:

On the command line, linker options are not case-sensitive—for example, /base and /BASE mean the same thing. For details on how to specify each option on the command line or in Visual Studio, see the documentation for that option.

You can use the comment pragma to specify some linker options.

OptionPurpose
@Specifies a response file.
/ALIGNSpecifies the alignment of each section.
/ALLOWBINDSpecifies that a DLL cannot be bound.
/ALLOWISOLATIONSpecifies behavior for manifest lookup.
/APPCONTAINERSpecifies whether the app must run within an appcontainer process environment.
/ASSEMBLYDEBUGAdds the DebuggableAttribute to a managed image.
/ASSEMBLYLINKRESOURCECreates a link to a managed resource.
/ASSEMBLYMODULESpecifies that a Microsoft intermediate language (MSIL) module should be imported into the assembly.
/ASSEMBLYRESOURCEEmbeds a managed resource file in an assembly.
/BASESets a base address for the program.
/CGTHREADSSets number of cl.exe threads to use for optimization and code generation when link-time code generation is specified.
/CLRIMAGETYPESets the type (IJW, pure, or safe) of a CLR image.
/CLRSUPPORTLASTERRORPreserves the last error code of functions that are called through the P/Invoke mechanism.
/CLRTHREADATTRIBUTESpecifies the threading attribute to apply to the entry point of your CLR program.
/CLRUNMANAGEDCODECHECKSpecifies whether the linker will apply the SuppressUnmanagedCodeSecurity attribute to linker-generated PInvoke stubs that call from managed code into native DLLs.
/DEBUGCreates debugging information.
/DEBUGTYPESpecifies which data to include in debugging information.
/DEFPasses a module-definition (.def) file to the linker.
/DEFAULTLIBSearches the specified library when external references are resolved.
/DELAYControls the delayed loading of DLLs.
/DELAYLOADCauses the delayed loading of the specified DLL.
/DELAYSIGNPartially signs an assembly.
/DLLBuilds a DLL.
/DRIVERCreates a kernel mode driver.
/DYNAMICBASESpecifies whether to generate an executable image that can be randomly rebased at load time by using the address space layout randomization (ASLR) feature.
/ENTRYSets the starting address.
/errorReportReports internal linker errors to Microsoft.
/EXPORTExports a function.
/FIXEDCreates a program that can be loaded only at its preferred base address.
/FORCEForces a link to complete even with unresolved symbols or symbols defined more than once.
/FUNCTIONPADMINCreates an image that can be hot patched.
/GENPROFILE, /FASTGENPROFILEBoth of these options specify generation of a .pgd file by the linker to support profile-guided optimization (PGO). /GENPROFILE and /FASTGENPROFILE use different default parameters.
/GUARDEnables Control Flow Guard protection.
/HEAPSets the size of the heap, in bytes.
/HIGHENTROPYVASpecifies support for high-entropy 64-bit address space layout randomization (ASLR).
/IDLOUTSpecifies the name of the .idl file and other MIDL output files.
/IGNORESuppresses output of specified linker warnings.
/IGNOREIDLPrevents the processing of attribute information into an .idl file.
/IMPLIBOverrides the default import library name.
/INCLUDEForces symbol references.
/INCREMENTALControls incremental linking.
/INTEGRITYCHECKSpecifies that the module requires a signature check at load time.
/KEYCONTAINERSpecifies a key container to sign an assembly.
/KEYFILESpecifies a key or key pair to sign an assembly.
/LARGEADDRESSAWARETells the compiler that the application supports addresses larger than two gigabytes
/LIBPATHSpecifies a path to search before the environmental library path.
/LTCGSpecifies link-time code generation.
/MACHINESpecifies the target platform.
/MANIFESTCreates a side-by-side manifest file and optionally embeds it in the binary.
/MANIFESTDEPENDENCYSpecifies a <dependentAssembly> section in the manifest file.
/MANIFESTFILEChanges the default name of the manifest file.
/MANIFESTINPUTSpecifies a manifest input file for the linker to process and embed in the binary. You can use this option multiple times to specify more than one manifest input file.
/MANIFESTUACSpecifies whether User Account Control (UAC) information is embedded in the program manifest.
/MAPCreates a mapfile.
/MAPINFOIncludes the specified information in the mapfile.
/MERGECombines sections.
/MIDLSpecifies MIDL command-line options.
/NOASSEMBLYSuppresses the creation of a .NET Framework assembly.
/NODEFAULTLIBIgnores all (or the specified) default libraries when external references are resolved.
/NOENTRYCreates a resource-only DLL.
/NOLOGOSuppresses the startup banner.
/NXCOMPATMarks an executable as verified to be compatible with the Windows Data Execution Prevention feature.
/OPTControls LINK optimizations.
/ORDERPlaces COMDATs into the image in a predetermined order.
/OUTSpecifies the output file name.
/PDBCreates a program database (PDB) file.
/PDBALTPATHUses an alternate location to save a PDB file.
/PDBSTRIPPEDCreates a program database (PDB) file that has no private symbols.
/PGDSpecifies a .pgd file for profile-guided optimizations.
/PROFILEProduces an output file that can be used with the Performance Tools profiler.
/RELEASESets the Checksum in the .exe header.
/SAFESEHSpecifies that the image will contain a table of safe exception handlers.
/SECTIONOverrides the attributes of a section.
/STACKSets the size of the stack in bytes.
/STUBAttaches an MS-DOS stub program to a Win32 program.
/SUBSYSTEMTells the operating system how to run the .exe file.
/SWAPRUNTells the operating system to copy the linker output to a swap file before it is run.
/TLBIDSpecifies the resource ID of the linker-generated type library.
/TLBOUTSpecifies the name of the .tlb file and other MIDL output files.
/TSAWARECreates an application that is designed specifically to run under Terminal Server.
/VERBOSEPrints linker progress messages.
/VERSIONAssigns a version number.
/WHOLEARCHIVEIncludes every object file from specified static libraries.
/WINMDEnables generation of a Windows Runtime Metadata file.
/WINMDFILESpecifies the file name for the Windows Runtime Metadata (winmd) output file that's generated by the /WINMD linker option.
/WINMDKEYFILESpecifies a key or key pair to sign a Windows Runtime Metadata file.
/WINMDKEYCONTAINERSpecifies a key container to sign a Windows Metadata file.
/WINMDDELAYSIGNPartially signs a Windows Runtime Metadata (.winmd) file by placing the public key in the winmd file.
/WXTreats linker warnings as errors.

For more information, see Compiler-Controlled LINK Options.

C/C++ Building Reference
Setting Linker Options
Frequently Asked Questions on Building

Show: