共用方式為


Linker Options 

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

The table below is a comprehensive list of options for LINK.exe. This section also includes information on:

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

You can specify some linker options via 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

/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 in spite of 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.

/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 having been 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 with 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 running it

/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 specifically designed to run under Terminal Server

/VERBOSE

Prints linker progress messages

/VERSION

Assigns a version number

/WX

Treat linker warnings as errors.

For related information, see Compiler-Controlled LINK Options.

See Also

Reference

Setting Linker Options
Frequently Asked Questions on Building

Other Resources

C/C++ Building Reference