Compaq COBOL AAQ2G1FTK User Manual

Page 52

Advertising
background image

Developing Compaq COBOL Programs
1.2 Developing Programs on Tru64 UNIX

1.2.3.5 Shared Library Restrictions

When creating a shared library using

ld

, be aware of the following restrictions:

Programs that are installed

setuid

or

setgid

will not use any libraries that

have been installed using the

inlib

shell command, but only systemwide

shared libraries (for security reasons).

For other restrictions imposed by the operating system, see your operating
system documentation. If you create a shared library that contains
routines written in C, refer to your operating system documentation for
any restrictions associated with the

cc

command.

1.2.3.6 Installing Shared Libraries

Once the shared library is created, it must be installed before you run a program
that refers to it. The following describes how you can install a shared library for
private or systemwide use:

To install a private shared library, such as for testing, set the environment
variable LD_LIBRARY_PATH, as described in ld(1).

To install a systemwide shared library, place the shared library file in one of
the standard directory paths used by

ld

(see ld(1).

For complete information on installing shared libraries, see your operating system
documentation.

Specifying Shared Object Libraries

When you link your program with a shared library, all symbols must be
referenced before

ld

searches the shared library, so you should always specify

libraries at the end of the

cobol

command line after all file names. Unless

you specify the

-non_shared

flag, shared libraries will be searched before the

corresponding archive libraries.

For instance, the following command generates an error if the file

rest.o

references routines in the library

libX

:

% cobol -call_shared test.cob -lX rest.o

The correct order follows:

% cobol -call_shared test.cob rest.o -lX

Link errors can occur with symbols that are defined twice, as when both an
archive and shared object are specified on the same command line. In general,
specify any archive libraries after the last file name, followed by any shared
libraries at the end of the command line.

Before you reference a shared library at run time, it must be installed.

1.2.3.7 Interpreting Messages from the Linker

If the linker detects any errors while linking object modules, it displays messages
about their cause and severity. If any errors occur, the linker does not produce an
image file.

Linker messages are descriptive, and you do not normally need additional
information to determine the specific error. The general format for

ld

messages

follows:

ld:
message-text

1–22 Developing Compaq COBOL Programs

Advertising