Developing Compaq COBOL Programs
1.2 Developing Programs on Tru64 UNIX
1.2.3.3 Specifying Types of Object Libraries
Certain
cobol
flags influence whether
ld
searches for an archive (
.a
) or shared
object (
.so
) library on the standard list of COBOL libraries and any additional
libraries specified using the
-l
string or
-L
dir flags. These flags are the following:
•
The
-call_shared
flag, the default, indicates that
.so
files are searched
before
.a
files. As
ld
attempts to resolve external symbols, it looks at the
shared library first before the corresponding archive library. References
to symbols found in a
.so
library are dynamically loaded into memory at
run time. References to symbols found in
.a
libraries are loaded into the
executable image file at link time. For instance,
/usr/shlib/libc.so
is
searched before
/usr/lib/libc.a
.
•
The
-non_shared
flag indicates that only
.a
files are searched, so the object
module created contains static references to external routines and are loaded
into the executable image at link time, not at run time. Corresponding
.so
files are not searched.
The following example requests that the standard
cobol .a
files be searched
instead of the corresponding
.so
files:
% cobol -non_shared mainprog.cob rest.o
External references found in an archive library result in that routine being
included in the resulting executable program file at link time.
External references found in a shared object library result in a special link to
that library being included in the resulting executable program file, instead of the
actual routine itself. When you run the program, this link gets resolved by either
using the shared library in memory (if it already exists) or loading it into memory
from disk.
1.2.3.4 Creating Shared Object Libraries
To create a shared library, first create the
.o
file, such as
octagon.o
in the
following example:
% cobol
-O3 -c octagon.cob
The file
octagon.o
is then used as input to the
ld
command to create the shared
library, named
octagon.so
:
% ld -shared -no_archive octagon.o \
-lcob -lcurses -lFutil -lots2 -lots -lisam -lsort -lexc -lmld -lm
A description of each
ld
flag follows:
•
The
-shared
flag is required to create a shared library.
•
The
-no_archive
flag indicates that
ld
should not search archive libraries to
resolve external names (only shared libraries).
•
The name of the object module is
octagon.o
. You can specify multiple
.o
files.
•
The
-lcob
and subsequent flags are the standard list of libraries that the
COBOL command would have otherwise passed to
ld
. When you create a
shared library, all symbols must be resolved. For more information about the
standard list of libraries used by Compaq COBOL, see Section 1.2.3.2.
Developing Compaq COBOL Programs 1–21
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......