### Linker Search Rules

When searching for an object (.obj) or library (.lib), the linker looks only in the specified directory if a path is indicated. If a path is not specified, the linker looks in the following locations in this order:

1. The current directory. Default libraries do not include path specifications.
2. Any directories you enter on the command line (they must end with a slash (/) or backslash (\) character so the linker recognizes the input as a path).
3. Any directories listed in the LIB environment variable.

If the linker cannot locate a file, it generates an error message and stops linking.

In addition to the libraries you specify, by default the linker searches the IBM C and C++ Compilers runtime libraries defined in your object files at compile time and the system import library, KERNEL32.LIB (Windows) or OS2386.LIB (OS/2).

#### Example

A response file contains the following information:

>     FUN.OBJ TEXT.OBJ TABLE.OBJ CARE.OBJ
>     NEWLIBV3.LIB
>     C:\TESTLIB\

The linker links four object files to create an executable file named FUN.EXE. The linker searches NEWLIBV3.LIB before searching the default libraries to resolve references.

To locate NEWLIBV3.LIB and the default libraries, the linker searches the following locations in this order:

1. The current directory (because NEWLIBV3.LIB was entered without a path).
2. The C:\TESTLIB\ directory.
3. The directories listed in the LIB environment variable.

Linking