Linker Options

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

The table that follows is a comprehensive list of options for LINK.exe. This section also includes information about:

Linker options specified on the command line are not case sensitive: /base and /BASE mean the same thing.

You can specify some linker options by using the comment pragma.

Option

Purpose

@

Specifies a response file

/ALIGN

Specifies the alignment of each section

/ALLOWBIND

Specifies that a DLL cannot be bound

/ALLOWISOLATION

Specifies behavior for manifest lookup.

/ASSEMBLYDEBUG

Adds the DebuggableAttribute to a managed image.

/ASSEMBLYLINKRESOURCE

Create a link to a managed resource.

/ASSEMBLYMODULE

Specifies that a Microsoft intermediate language (MSIL) module should be imported into the assembly

/ASSEMBLYRESOURCE

Embeds a managed resource file to an assembly

/BASE

Sets a base address for the program

/CLRIMAGETYPE

Sets the type (IJW, pure, or safe) of a CLR image.

/CLRSUPPORTLASTERROR

Preserves the last error code of functions called through the P/Invoke mechanism.

/CLRTHREADATTRIBUTE

Specify which threading attribute you want applied to the entry point of your CLR program.

/CLRUNMANAGEDCODECHECK

/CLRUNMANAGEDCODECHECK specifies whether the linker will apply the SuppressUnmanagedCodeSecurity attribute to linker-generated PInvoke stubs that call from managed code into native DLLs.

/DEBUG

Creates debugging information

/DEF

Passes a module-definition (.def) file to the linker

/DEFAULTLIB

Searches the specified library when resolving external references

/DELAY

Controls the delayed loading of DLLs

/DELAYLOAD

Causes the delayed loading of the specified DLL

/DELAYSIGN

Partially sign an assembly.

/DLL

Builds a DLL

/DRIVER

Creates a Windows NT kernel mode driver

/DYNAMICBASE

Specifies whether to generate an executable image that can be randomly rebased at load-time by using the address space layout randomization (ASLR) feature of Windows Vista.

/ENTRY

Sets the starting address

/errorReport

Report internal linker errors to Microsoft.

/EXPORT

Exports a function

/FIXED

Creates a program that can be loaded only at its preferred base address

/FORCE

Forces a link to complete even with unresolved or symbols defined more than once

/FUNCTIONPADMIN

Creates a hotpatchable image.

/HEAP

Sets the size of the heap in bytes

/IDLOUT

Specifies the name of the .idl file and other MIDL output files

/IGNOREIDL

Prevents processing attribute information into an .idl file

/IMPLIB

Overrides the default import library name

/INCLUDE

Forces symbol references

/INCREMENTAL

Controls incremental linking

/KEYCONTAINER

Specify a key container to sign an assembly.

/KEYFILE

Specify key or key pair to sign an assembly.

/LARGEADDRESSAWARE

Tells the compiler that the application supports addresses larger than two gigabytes

/LIBPATH

Allows the user to override the environmental library path

/LTCG

Specifies link-time code generation

/MACHINE

Specifies the target platform

/MANIFEST

Create a side-by-side manifest file.

/MANIFESTDEPENDENCY

Specify a <dependentAssembly> section in your manifest file.

/MANIFESTFILE (Name Manifest File)

Change the default name of the manifest file.

/MANIFESTUAC

Specifies whether User Account Control (UAC) information is embedded in the program manifest.

/MAP

Creates a mapfile

/MAPINFO

Includes the specified information in the mapfile

/MERGE

Combines sections

/MIDL

Specifies MIDL command-line options

/NOASSEMBLY

Suppresses the creation of a .NET Framework assembly

/NODEFAULTLIB

Ignores all (or specified) default libraries when resolving external references

/NOENTRY

Creates a resource-only DLL

/NOLOGO

Suppresses startup banner

/NXCOMPAT

Marks an executable as tested to be compatible with Windows Data Execution Prevention feature.

/OPT

Controls LINK optimizations

/ORDER

Places COMDATs into the image in a predetermined order

/OUT

Specifies the output file name

/PDB

Creates a program database (PDB) file

/PDBSTRIPPED

Creates a program database (PDB) file that has no private symbols

/PGD

Specify .pgd file for profile guided optionizations.

/PROFILE

Produces an output file that can be used with the Performance Tools profiler.

/RELEASE

Sets the Checksum in the .exe header

/SAFESEH

Specify that the image will contain a table of safe exception handlers.

/SECTION

Overrides the attributes of a section

/STACK

Sets the size of the stack in bytes

/STUB

Attaches an MS-DOS stub program to a Win32 program

/SUBSYSTEM

Tells the operating system how to run the .exe file

/SWAPRUN

Tells the operating system to copy the linker output to a swap file before it is run

/TLBID

Allows you to specify the resource ID of the linker-generated type library

/TLBOUT

Specifies the name of the .tlb file and other MIDL output files

/TSAWARE

Creates an application that is designed specifically to run under Terminal Server

/VERBOSE

Prints linker progress messages

/VERSION

Assigns a version number

/WX

Treat linker warnings as errors.

For more information, see Compiler-Controlled LINK Options.

See Also

Reference

Setting Linker Options

Frequently Asked Questions on Building

Other Resources

C/C++ Building Reference