Linker and Libraries Guide

Static Mode

Static mode is selected when the -d n option is used, and enables you to create relocatable objects and static executables. Under this mode, only relocatable objects and archive libraries are acceptable forms of input. Use of the -l option results in a search for archive libraries.

Creating a Relocatable Object

$ cc -dn -r -o temp.o file1.o file2.o file3.o .....

Creating a Static Executable

The use of static executables is limited. See Static Executables. Static executables usually contain platform-specific implementation details that restricts the ability of the executable to be run on an alternative platform. Many implementations of Solaris OS libraries depend on dynamic linking capabilities, such as dlopen(3C) and dlsym(3C). See Loading Additional Objects. These capabilities are not available to static executables.

$ cc -dn -o prog file1.o file2.o file3.o .....

The -a option is available to indicate the creation of a static executable. The use of -d n without a -r implies -a.