United States |
Previous | Contents | Index |
The Compaq C RTL object libraries are used solely for linking programs compiled without /PREFIX=ALL.
On OpenVMS Alpha systems, the Compaq C RTL provides the following object libraries in the ALPHA$LIBRARY directory:
The object library VAXCCURSE.OLB, which provides access to the curses functions, contains unprefixed entry points that vector to the appropriate prefixed entry points.
The object libraries VAXCRTL.OLB, VAXCRTLD.OLB, VAXCRTLT.OLB, VAXCRTLX.OLB, VAXCRTLDX.OLB, and VAXCRTLTX.OLB also contain unprefixed entry points that vector to the appropriate prefixed entry points, depending on the floating-point type specified by the object library used:
/L_DOUBLE_SIZE=128 is the default.
On the LINK command, specify only one of the VAXCRTL*.OLB libraries and, if needed, the VAXCCURSE.OLB library.
In the default mode of the compiler (/STANDARD=RELAXED_ANSI89) and also in strict ANSI C mode, all calls to ANSI C standard library routines are automatically prefixed with DECC$. With the /[NO]PREFIX_LIBRARY_ENTRIES qualifier, you can change this to prefix all Compaq C RTL names with DECC$, or to not prefix any Compaq C RTL names. Other options are also available for this qualifer. See the /[NO]PREFIX_LIBRARY_ENTRIES qualifier in this chapter for more information.
When linking with /NOSYSSHR, if calls to the Compaq C RTL routines are prefixed with DECC$, then the modules in STARLET.OLB are the only ones you need to link against. Since STARLET.OLB is automatically searched by the linker (unless the link qualifier /NOSYSLIB is used), all prefixed RTL external names are automatically resolved.
If any calls to the Compaq C RTL routines are not prefixed, then you
need to explicitly link against VAXCRTL.OLB, VAXCRTLD.OLB, VAXCRTLT.OLB
(or VAXCRTLX.OLB, VAXCRTLDX.OLB, or VAXCRTLDX.OLB), or VAXCCURSE.OLB,
depending on which floating-point types you need, or if you want curses
functions. If you are linking with /NOSYSSHR, prefixed Compaq C RTL
entry points are resolved in STARLET.OLB. If you are linking with
/SYSSHR (the default), prefixed Compaq C RTL entry points are resolved
in DECC$SHR.EXE.
1.2.3 Examples
The following examples show several different ways you might want to link with the Compaq C RTL. See Figure 1-1 for a graphical summary of these examples.
$ CC/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES PROG1 $ LINK PROG1 |
$ CC/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES PROG1 $ LINK/NOSYSSHR PROG1 |
|
$ CC/NOPREFIX_LIBRARY_ENTRIES PROG1 $ LINK PROG1, MYLIB/LIBRARY, ALPHA$LIBRARY:VAXCRTLX.OLB/LIBRARY |
$ CC/NOPREFIX_LIBRARY_ENTRIES/FLOAT=IEEE_FLOAT PROG1 $ LINK PROG1, MYLIB/LIBRARY, ALPHA$LIBRARY:VAXCRTLTX.OLB/LIBRARY |
$ CC/NOPREFIX_LIBRARY_ENTRIES PROG1 $ LINK/NOSYSSHR PROG1, MYLIB/LIBRARY, ALPHA$LIBRARY:VAXCRTLX.OLB/LIBRARY |
Figure 1-1 Linking with the Compaq C RTL on OpenVMS Alpha Systems
Both the VAX C RTL and the Compaq C RTL can coexist on your OpenVMS VAX system. The VAX C RTL supports existing VAX C applications. The Compaq C RTL supports ANSI-compliant Compaq C and Compaq C++, as well as other components of the OpenVMS environment. The Compaq C RTL also provides a mechanism for thread safety and performance improvements.
Applications developed with VAX C will continue to use the VAX C RTL. However, you can relink VAX C applications to use the Compaq C RTL instead. This lets you take advantage of the new features of the Compaq C RTL and solve potential interoperability problems in complex applications that incorporate both the VAX C RTL and the Compaq C RTL. Existing applications that are relinked to use the Compaq C RTL should be carefully tested for possible problems resulting from the differences in behavior between the VAX C RTL and the Compaq C RTL. See the applicable Compaq C release notes and OpenVMS release notes for more information.
The following sections describe several ways of linking Compaq C
programs with the Compaq C RTL and VAX C RTL on OpenVMS VAX
systems.
1.3.1 Linking with the Compaq C RTL
The Compaq C RTL provides a new set of files with different names from
the VAX C RTL files. If you want to link with the Compaq C RTL, you
need to change your link procedures to use the new file names. The
following sections describe linking with the Compaq C RTL files.
1.3.1.1 Linking with the Compaq C RTL Shareable Images
Most linking needs should be satisfied by using the Compaq C RTL shareable image DECC$SHR.EXE in the SYS$LIBRARY directory. Use this linking method for programs that are written entirely in Compaq C or Compaq C++ code; that is, with no VAX C object modules.
Because DECC$SHR.EXE exports only prefixed universal symbols (ones that begin with DECC$), to successfully link against it make sure you cause prefixing to occur for all Compaq C RTL entry points.
If you use only the Compaq C RTL functions defined in the ANSI C Standard, all entry points will be prefixed.
If you use Compaq C RTL functions not defined in the ANSI C Standard, you must compile in one of two ways to ensure prefixing:
Then link against the shareable image using the LINK command. For example:
$ LINK PROG1 |
If you are using the VAX C compiler and you want to link with DECC$SHR.EXE, you must link to one of the following files:
VAXC2DECC.EXE
VAXCG2DECC.EXE
You link with them as follows:
$ LINK PROG1,TT:/OPTIONS SYS$LIBRARY:VAXC2DECC/SHARE [Ctrl/Z] |
Use the G-floating version, VAXCG2DECC.EXE, if you compiled with the
/G_FLOAT or /FLOAT=G_FLOAT qualifier.
1.3.1.2 Linking with or Providing Your Own Shareable Images
Most linking needs for an application using a shareable image are handled by a straight forward link command, regardless of whether the shared image uses Compaq C, VAX C or some other programming language.
For example, assume that SHARE1.EXE is a shareable image linked with VAXCRTL.EXE. Also assume that your program, PROG1, is compiled with Compaq C and, therefore, references prefixed names for C RTL functions. You can then use the following commands:
$ LINK PROG1, SYS$INPUT:/OPTIONS MYDISK:[TEXT]SHARE1.EXE/SHARE |
If PROG1 does not use prefixed names, the link could result in link
conflicts. If this occurs, see Section 1.3.2.
1.3.1.3 Linking with the Compaq C RTL Object Libraries
The Compaq C RTL object libraries are used primarily for linking with the /NOSYSSHR qualifier.
On OpenVMS VAX systems, the Compaq C RTL provides the following object libraries in the SYS$LIBRARY directory:
As with VAX C, if you specify more than one object library on the LINK command, you must do so in the order listed.
You use these object libraries in the same way that you would use the VAX C RTL object libraries VAXCRTL.OLB, VAXCRTLG.OLB, and VAXCCURSE.OLB. For example:
$ ! Link a D-float program $ LINK PROG1, SYS$LIBRARY:DECCRTL.OLB/LIBRARY $ ! $ ! Link a G-float program $ LINK PROG2, SYS$LIBRARY:DECCRTLG.OLB/LIBRARY, - _$ SYS$LIBRARY:DECCRTL.OLB/LIBRARY $ ! $ ! Link a D-float, curses program $ LINK PROG1, SYS$LIBRARY:DECCCURSE.OLB/LIBRARY, - _$ SYS$LIBRARY:DECCRTL.OLB/LIBRARY |
If you want to link your program with the Compaq C RTL object libraries using the /NOSYSSHR qualifier, you must specify /INCLUDE=CMA$TIS for the object library. Otherwise, several symbols will be undefined and the resulting image will not execute.
In order to add this qualifier, you cannot use the LNK$LIBRARY logicals to link with the Compaq C RTL. You must use a linker options file or list the Compaq C RTL object library on the command line. For example:
$ LINK/NOSYSSHR PROG1, SYS$LIBRARY:DECCRTL.OLB/LIBRARY/INCLUDE=CMA$TIS |
|
This section describes the use of interoperability tools to resolve link-time conflicts when using multiple C RTLs.
When migrating to the Compaq C RTL, multiple C RTLs will likely be needed to link an application. One C RTL might be explicitly linked against. A second C RTL might not be explicitly linked against, but brought into the link by means of a shareable image. For example, when developing a Motif program using Compaq C, the application must be linked against the Compaq C RTL and against the Motif images. Motif currently brings the VAX C RTL into the link.
Problems encountered when linking with multiple C RTLs are a result of the OpenVMS linker resolving symbol references in the image being linked by searching the transitive closure of shareable images and libraries. That is, when linking with a shareable image, the linker searches that shareable image and all shareable images referenced in that shareable image. So when linking with VAXCRTL.EXE and with an image linked with VAXCRTLG.EXE, the linker will find two instances of all the C RTL symbols (one in VAXCRTL and one in VAXCRTLG), and report a conflict.
The object libraries do not conflict with routine names, but do conflict with the global symbols. Because VAX C implements global symbols as global overlaid psects, the linker attempts to connect all the instances of a C-generated psect with the same name. For example, a reference to stdin in the user program is connected with the psect of the same name in VAXCRTL.OLB. However, a shareable image that was linked with VAXCRTL.OLB also has a psect of the same name; this results in an error because the linker cannot connect those two definitions of the psect stdin .
Three interoperability tools are provided with the Compaq C compiler and in a separate Compaq C/C++ RTL Run-Time Components kit to resolve link-time conflicts:
These tools work by hiding the conflicting symbols from one of the C RTLs being linked. Which tool is required depends on what C RTLs are used by the main application and the shareable image.
Table 1-1 shows typical C RTL conflicts and the interoperability tool required to resolve it. In the table, VAXCRTL.EXE refers to either VAXCRTL.EXE or VAXCRTLG.EXE.
Linker Message | Type of Conflict | Tool Needed |
---|---|---|
LINK-E-MULSHRPSC | VAXCRTL.OLB/VAXCRTL.EXE | VAXC$LCL.OPT |
LINK-E-SHRPSCLNG | VAXCRTL.OLB/DECCRTL.OLB | VAXC$LCL.OPT |
LINK-E-MULSHRPSC,
LINK-E-SHRPSCLNG |
DECCRTL.OLB/VAXCRTL.EXE | VAXC$LCL.OPT |
None. | DECCRTL.OLB/DECC$SHR.EXE | DECC$EMPTY |
LINK-W-MULDEF | VAXCRTL.EXE/VAXCRTLG.EXE | VAXC$EMPTY |
LINK-W-MULDEF | VAXC2DECC.EXE/VAXCRTL.EXE | VAXC$EMPTY |
VAXC$LCL.OPT is required when building any shareable image linked with the VAX C RTL object library or Compaq C RTL object library.
If the shareable image is built without using VAXC$LCL.OPT, the C RTL global symbols are visible in the shareable image and cause linker conflicts when users of the image link against it. For example:
%LINK-E-MULSHRPSC, psect C$$TRNS_VALUES defined in shareable image IMAGE1.EXE; is multiply defined in shareable image SYS$LIBRARY:VAXCRTL.EXE;1 -LINK-E-NOIMGFIL, image file not created |
In this example, the shareable image IMAGE1 uses VAXCRTL.OLB, and the image being linked uses VAXCRTL.EXE. For a successful link, relink the shareable image using VAXC$LCL.OPT:
$ LINK/SHARE IMAGE1.OBJ, IMAGE1.OPT/OPTIONS, SYS$LIBRARY:VAXCRTL/LIBRARY, - _$ SYS$LIBRARY:VAXC$LCL.OPT/OPTIONS |
The following message also indicates a conflict involving the VAX C RTL object library:
%LINK-E-SHRPSCLNG, Psect STDIN has length of 8 in module C$EXTERNDATA file SYS$LIBRARY:DECCRTL.OLB;2 which exceeds length of 4 in shareable image IMAGE1.EXE; -LINK-E-NOIMGFIL, image file not created |
In this example, the shareable image IMAGE1 uses VAXCRTL.OLB, and the image being linked uses DECCRTL.OLB. For a successful link, relink the shareable image using VAXC$LCL.OPT.
If the shareable image cannot be relinked (as in the case of a third-party shareable image), then the interoperability tool can be applied to the main image. If the main image is being linked against DECCRTL.OLB, then apply VAXC$LCL.OPT to the link of the main image.
If the main image is being linked against VAXCRTL.EXE, the only
solution is to get the shareable image fixed, because applying any of
the interoperability tools to the link of the main image will result in
an unsuccessful link.
1.3.2.2 Using VAXC$EMPTY.EXE
Use VAXC$EMPTY.EXE to link a main application with both VAXC2DECC.EXE (or VAXCG2DECC.EXE) and a shareable image linked with VAXCRTL.EXE (or VAXCRTLG.EXE). Using VAXC$EMPTY.EXE hides all the global symbols in the VAXCRTL*.EXE shareable image to prevent conflicts with VAXC2DECC.EXE or VAXCG2DECC.EXE.
Also use VAXC$EMPTY.EXE to link an application with both VAXCRTL.EXE and a shareable image linked with VAXCRTLG.EXE (or vice versa).
When there is a conflict between C RTL shareable images, the linker produces large numbers of messages similar to the following:
%LINK-W-MULDEF, symbol ACOS multiply defined in module VAXCRTL file SYS$COMMON:[SYSLIB]VAXCRTL.EXE;18 |
In this example, the shareable image is linked with VAXCRTL.EXE, and the main program is linked with VAXC2DECC.EXE.
The solution is to define the VAXCRTL logical to point to VAXC$EMPTY.EXE before linking the main program:
$ DEFINE/USER VAXCRTL SYS$LIBRARY:VAXC$EMPTY.EXE $ LINK/EXEC=MAIN_IMAGE MAIN_PROG,OBJ1,OBJ2,...,SYS$INPUT:/OPTIONS IMAGE1/SHARE VAXCRTL/SHARE [Ctrl/Z] |
Note the following about this solution:
Follow the same process when linking against VAXCRTLG.EXE by defining
the VAXCRTLG logical to point to VAXC$EMPTY.EXE.
1.3.2.3 Using DECC$EMPTY.EXE
The DECC$EMPTY.EXE interoperability tool allows a program to use the Compaq C object library even when the program links with a shareable image that was linked with DECC$SHR.EXE.
If DECC$EMPTY.EXE is not used during the link, all Compaq C RTL references from the main program will be resolved in DECC$SHR.EXE, not in the object library. There is no linker message that indicates this fact.
For example, if IMAGE1 is linked against DECC$SHR, and the following link is performed, then the main image will not contain any Compaq C RTL object modules. All C RTL references from the main progam are resolved in DECC$SHR:
$ LINK/EXEC=MAIN_IMAGE MAIN_PROG,OBJ1,...,SYS$INPUT:/OPTIONS IMAGE1/SHARE SYS$LIBRARY:DECCRTL/LIBRARY [Ctrl/Z] |
By defining the DECC$SHR logical to point to DECC$EMPTY.EXE immediately before the link, all references to C RTL symbols from the main program are resolved in the Compaq C RTL object library. For example:
$ DEFINE/USER DECC$SHR SYS$LIBRARY:DECC$EMPTY.EXE $ LINK/EXEC=MAIN_IMAGE MAIN_PROG,OBJ1,...,SYS$INPUT:/OPTIONS IMAGE1/SHARE SYS$LIBRARY:DECCRTL/LIBRARY |
Note the following about this solution:
Previous | Next | Contents | Index |
|