Linker switches

The following shows an example of specifying the linker command line options


+link
{
    /OUT:"$(EXPORT)/$(PLATFORM)/$(CONFIG)/
    $(PROJNAME).$(TGT_EXTENSION)"
    /PDB:"$(EXPORT)/$(PLATFORM)/$(CONFIG)/
    $(PROJNAME).pdb"
    /LARGEADDRESSAWARE
    /DEBUG
    /NOLOGO
}
+link("Dynamic-Link Library")
{
    /DLL
    /IMPLIB:"$(EXPORT)/$(PLATFORM)/$(CONFIG)/
    $(PROJNAME)/$(PROJNAME).lib"
}
+link("Release")
{
    /PROFILE
    /MAP:"$(EXPORT)/$(PLATFORM)/$(CONFIG)/
    $(PROJNAME).map"
    /INCREMENTAL:NO
    /OPT:REF /OPT:ICF
}
+link("Debug")
{
    /INCREMENTAL
}
+link("Console Application")
{
    /SUBSYSTEM:CONSOLE
}
+link("Application|Win32")
{
    /SUBSYSTEM:WINDOWS
}
+link("Win32")
{
    /MACHINE:X86
    /MANIFEST
    /MANIFESTFILE:"$(PLATFORM)/$(CONFIG)/
    $(PROJNAME)/$(PROJNAME).$(TGT_EXTENSION)
    .intermediate.manifest"
    "kernel32.lib"
    "user32.lib"
    "gdi32.lib"
    "winspool.lib"
    "comdlg32.lib"
    "advapi32.lib"
    "shell32.lib"
    "ole32.lib"
    "oleaut32.lib"
    "uuid.lib"
    "odbc32.lib"
    "odbccp32.lib"
}
+link("WinCE")
{
    /SUBSYSTEM:WINDOWSCE,4.20
    /MACHINE:ARM
    /ARMPADCODE
    /MANIFEST:NO
    /NODEFAULTLIB:"oldnames.lib"
    /STACK:65536,4096
    "coredll.lib"
    "corelibc.lib"
    "ole32.lib"
    "oleaut32.lib"
    "uuid.lib"
    "commctrl.lib"
}

Note the following:

Supported switches


General
-------

    Output file
        /OUT:"pathToOutputFile"

    Show progess
        /VERBOSE                        Display all progrsss messages
        /VERBOSE:LIB                    Display some progrsss messages

    The version number in the created image header
        /VERSION:"version"

    Enable incremental linking
        /INCREMENTAL:NO                 No
        /INCREMENTAL                    Yes

    Suppress Startup Banner
        /NOLOGO                         Yes (suppress)

    Ignore Import Library
        Specifies that the import library generated by this configuration
        should not be imported into dependent projects
        [not supported by XCPP]

    Register Output
        Specifies whether to register the primary output of this build
        [not supported by XCPP]

    Additional Library Directories
        Specifies one or more additional paths to search for libraries; configuration specific;
        use semicolon delimited list if more than one
        /LIBPATH:"dir"

    Link library dependencies
        Specifies whether or not library output from project dependencies are automatically linked in
        [not supported by XCPP]

    Use library dependency inputs
        Specifies whether or not the inputs to the librarian tool are used rather than the library
        file itself when linking in library outputs of project dependencies.
        [not supported by XCPP]

    Use UNICODE Response Files
        Instructs the project system to generate UNICODE response files when spawning the linker.  Set this
        property to "Yes" when files in the project have UNICIDE paths.
        [not supported by XCPP]

Input
-----

    Additional Dependencies
        Specifies additional items to add to the link line

    Ignore All Default Libraries
        /NODEFAULTLIB

    Ignore Specific Libraries
        Specifies one or more names of default libraries to ignore
        /NODEFAULTLIB:[name]

    Module definition file
        /DEF:[path]

    Add module to assembly (i.e. import the specified non-assembly files into the final output)
        /ASSEMBLYMODULE:[path1]

    Embed managed (i.e. .NET) resource file
        /ASSEMBLYRESOURCE:[path]

    Force the linker to include a reference to this symbol
        /INCLUDE:[symbol]

    Delay loaded DLLS
        Specifies one or more DLLs for delayed loading
        /DELAYLOAD:[dllname]

    Assembly link resource
        Links a resource to the output assembly.  The resource file is not placed in the output assembly,
        unlike the /ASSEMBLYRESOURCE switch
        /ASSEMBLYLINKRESOURCE:[file]

Manifest file
-------------

    Generate manifest
        /MANIFEST:NO                    No
        /MANIFEST                       Yes

    Manifest file
        Specifies the name of the manifest file to generate.  Only used if generation of manifest is enabled.
        /MANIFESTFILE:[file]

    Additional Manifest Dependencies
        Specifies the additional XML manifets fragements the linker will put in the manifest file
        /MANIFESTDEPENDENCY:[dependency]

    Allow isolation
        Specifies manifest file looup behaviour for side-by-side assemblies
        /ALLOWISOLATION:NO              No (don't allow side-by-side isolation)

Debugging
---------

    Generate debug info
        /DEBUG                          Yes

    Generate program database file
        /PDB:file

    Strip private symbols
        Do not put private symbols into the generated PDB file specified
        /PDBSTRIPPED:file

    Generate map file
        /MAP                            Yes

    Map file name
        /MAP:file

    Map exports
        Includes imported functions in map file information
        /MAPINFO:EXPORTS                Yes

    Debuggable assembly
        /ASSEMBLYDEBUG                  Runtime tracking and disable optimisations
        /ASSEMBLYDEBUG:DISABLE          No runtime tracking and enable optimisations

System
------

    SubSystem
        /SUBSYSTEM:CONSOLE
        /SUBSYSTEM:WINDOWS
        /SUBSYSTEM:NATIVE
        /SUBSYSTEM:EFI_APPLICATION
        /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
        /SUBSYSTEM:EFI_ROM
        /SUBSYSTEM:EFI_RUNTIME_DRIVER
        /SUBSYSTEM:POSIX
        /SUBSYSTEM:WINDOWSCE

    Heap Reserve Size
        /HEAP:reserve

    Heap Commit Size
        /HEAP:reserve,commit

    Stack reserve space
        /STACK:reserve

    Stack coimmit size
        /STACK:reserve,commit

    Enable large addresses
        /LARGEADDRESSAWARE:NO           Don't support addresses larger than 2GB
        /LARGEADDRESSAWARE              Support addresses larger than 2GB

    Terminal Server
        /TSAWARE:NO                     Not terminal server aware
        /TSAWARE                        Application is terminal server aware

    Swap Run from CD
        /SWAPRUN:CD                     Yes, run application from the swap location of the CD

    Swap run from network
        /SWAPRUN:NET                    Yes, run application from the swap location of the Net

    Driver
        Specifies the driver for the linker
        /DRIVER
        /DRIVER:UPONLY                  Up only
        /DRIVER:WDM                     WDM

Optimisation
------------

    References
        /OPT:NOREF                      Keep unreferenced data
        /OPT:REF                        Eliminate unreferenced data

    Enable COMDAT folding
        /OPT:NOICF                      Do not remove redundant COMDATs
        /OPT:ICF                        Remove redundant COMDATs

    Optimise for Windows98
        /OPT:NOWIN98                    No
        /OPT:WIN98                      Yes

    Function order
        Places COMDATs into the image in a predefined order; specify the file name defining the order;
        no incremental linking.
        /ORDER:file

    Profile Guided Database
        Specifies the database file to use when using profile guided optimisations.
        /PGD:database

    Link time code generation
        /LTCG                           Use link time code generation
        /LTCG:PGINSTRUMENT              Profile guided optimisation - Instrument
        /LTCG:PGOPTIMIZE                Profile guided optimisation - Optimise
        /LTCG:PGUPDATE                  Profile guided optimisation - Update

Embedded IDL
------------

    MIDL Commands
        /MIDL:file

    Ignore Embedded IDL
        /IGNOREIDL                      Yes

    Merged IDL Base file name
        /IDLOUT:file

    Type library
        /TLBOUT:filename

    TypeLib Resource ID
        /TLBID:id

Advanced
--------

    Entry Point
        /ENTRY:symbol

    No Entry Point
        /NOENTRY                        Yes

    Set Checksum
        /RELEASE                        Yes, enable setting the checksum in the header of an exe

    Base Address
        /BASE:address
        [todo: key not supported]

    Fixed Base Address
        /FIXED:NO
        /FIXED

    Turn off assembly generation
        /NOASSEMBLY

    Delay loaded DLL
        /DELAY:UNLOAD

    Import library
        /IMPLIB:name

    Merge sections
        /MERGE:from=to
        [todo: currently not supported in XCPP]

    Target machine
        /MACHINE:X86
        /MACHINE:IX86
        /MACHINE:I386
        /MACHINE:AM33
        /MACHINE:ARM
        /MACHINE:EBC
        /MACHINE:IA64
        /MACHINE:M32R
        /MACHINE:MIPS
        /MACHINE:MIPS16
        /MACHINE:MIPSFPU
        /MACHINE:MIPSFPU16
        /MACHINE:MIPSR41XX
        /MACHINE:SH3
        /MACHINE:SH3DSP
        /MACHINE:SH4
        /MACHINE:SH5
        /MACHINE:THUMB
        /MACHINE:X64

    Profile
        /PROFILE

    CLR Thread attribute
        /CLRTHREADATTRIBUTE:MTA
        /CLRTHREADATTRIBUTE:STA

    CLR Image type
        /CLRIMAGETYPE:IJW
        /CLRIMAGETYPE:PURE
        /CLRIMAGETYPE:SAFE

    Key file
        /KEYFILE:filename

    Key container
        /KEYCONTAINER:name

    Delay sign
        /DELAYSIGN                      Yes

    Error reporting
        Allows you to provide internal compiler error (ICE) information directly to the Visual C++ team

        /ERRORREPORT:NONE
        /ERRORREPORT:PROMPT
        /ERRORREPORT:QUEUE

    CLR Unmanage Code Check
        By default, the linker applies the SuppressUnmanagedCodeSecurityAttribute to linker-generated PInvoke calls.
        When /CLRUNMANAGEDCODECHECK is in effect, SuppressUnmanagedCodeSecurityAttribute is not applied.

        /CLRUNMANAGEDCODECHECK