-qlib, -nodefaultlibs (-qnolib)

Category

Linking

Pragma equivalent

None.

Purpose

Specifies whether standard system libraries and XL C/C++ libraries are to be linked.

When -qlib is in effect, the standard system libraries and compiler libraries are automatically linked. When -nodefaultlibs (-qnolib) is in effect, the standard system libraries and compiler libraries are not used at link time; only the libraries specified on the command line with the -l flag will be linked.

This option can be used in system programming to disable the automatic linking of unneeded libraries.

Syntax

Read syntax diagramSkip visual syntax diagram
>>- -nodefaultlibs---------------------------------------------><

Read syntax diagramSkip visual syntax diagram
        .-lib---.   
>>- -q--+-nolib-+----------------------------------------------><

Defaults

-qlib

Usage

Using -nodefaultlibs (-qnolib) specifies that no libraries, including the system libraries as well as the XL C/C++ libraries (these are found in the lib/ and lib64/ subdirectories of the compiler installation directory), are to be linked. The system startup files are still linked, unless -nostartfiles (-qnocrt) is also specified.

Note: If your program references any symbols that are defined in the standard libraries or compiler-specific libraries, link errors will occur. To avoid these unresolved references when compiling with -nodefaultlibs (-qnolib), be sure to explicitly link the required libraries by using the command flag -l and the library name.

Predefined macros

None.

Examples

To compile myprogram.c without linking to any libraries except the compiler library libxlopt.a, enter:
xlc myprogram.c -nodefaultlibs -lxlopt

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us