Solaris Internationalization Guide For Developers

Dynamically Linked Applications

Solaris 7 users can choose how to link applications with the system libraries, such as libc, by using dynamic linking or static linking. However, any application that requires internationalization features in the system libraries must be dynamically linked. If the application has been statically linked, the operation to set the locale to other than C and POSIX using the setlocale function will fail. Statically linked applications can be operated only in C and POSIX locales.

By default, the linker program tries to link the application dynamically. If the command line options to the linker and the compiler include -Bstatic or -dn specifications, your application may be statically linked. You can check whether an existing application is dynamically linked using the /usr/bin/ldd command.

For example, if you type:


% /usr/bin/ldd /sbin/sh

the command displays the following message:


% ldd: /sbin/sh: file is not a dynamic executable or shared object

The message indicates the /sbin/sh command is not a dynamically linked program. Also, if you type:


% /usr/bin/ldd /usr/bin/ls

the command displays the following message:


% libc.so.1 => 	/usr/lib/libc.so.1
% libdl.so.1 => /usr/lib/libdl.so.1

This message indicates the /usr/bin/ls command has been dynamically linked with two libraries, libc.so.1 and libdl.so.1.

To summarize, if the message from the ldd command to the application does not contain a libc.so.1 entry, it indicates that the application has been statically linked with libc. In that case, you need to change the command line options to the linker so that dynamic linking is used instead, then re-link the application.