### Choose Run-Time Libraries

When you compile, the compiler defines default IBM C and C++ Compilers runtime libraries for the linker to use. You can use compiler options to control the linking process by changing the type of runtime library you link to. If you do not specify any options, the compiler uses the library that produces statically linked single-thread executable modules. You may need to link to another library to:

- Dynamically link your program
- Create a multithread executable module
- Develop a subsystem
- Create a DLL for use with another executable module.

The defaults used by the compiler are:

- /Gd- (static linking)
- /Gm- (single-thread library)
- /Re (standard library)
- /Ge+ (to build an .exe file).

Compiler Options for Specifying Libraries
Linking Type | Threading | Library used | Module Type | Options required in addition to defaults
--- | --- | --- | --- | ---
Static | Single | Standard | EXE | None
Static | Single | Standard | DLL | /Ge-
Static | Multi | Standard | EXE | /Gm+
Static | Multi | Standard | DLL | /Gm+ /Ge-
Static | N/A | Subsystem | EXE | /Rn
Static | N/A | Subsystem | DLL | /Rn /Ge-
Dynamic | Single | Standard | EXE | /Gd+
Dynamic | Single | Standard | DLL | /Gd+ /Ge-
Dynamic | Multi | Standard | EXE | /Gd+ /Gm+
Dynamic | Multi | Standard | DLL | /Gd+ /Gm+ /Ge-
Dynamic | N/A | Subsystem | EXE | /Gd+ /Rn
Dynamic | N/A | Subsystem | DLL | /Gd+ /Rn /Ge-

Static and Dynamic Linking
Multithreaded Applications

Link with Library Files
Produce an Executable File
Produce a Device Driver
Produce a Dynamic Link Library

Library Naming Conventions