Chapter Contents

Previous

Next
Using the SAS/C Cross-Platform Compiler and C++ Development System

Linking C and C++ Programs

Linking in the cross-platform environment usually involves prelinking on the host system and then copying the prelinked file to the target system, either OS/390 or CMS, where the final linking occurs. Prelinking is performed by cool , which is normally called when you compile your source code. Final linking of the prelinked output on the mainframe can be accomplished with the IBM linkage editor or CMS LOAD and GENMOD commands.

Although prelinking is performed by default when you call the cross-platform compiler, you can suppress prelinking by specifying the -c compiler option. Note, however, that prelinking is required, either on the workstation or on the mainframe, if any of the following conditions are true:

If you do not call the prelinker during compilation, you can perform the prelinking in one of the following ways:

This section discusses each of these methods of prelinking.


Using cool

The prelinker, cool , is an executable file that can be called directly. The following is the syntax for invoking cool :

cool [options] [filename1 [filename2 ...]]

The options argument specifies any of the prelinker options described in Prelinking C and C++ Programs. You must use the -o option to specify an output file when you invoke cool . If you enter the cool command without specifying the -o option, an error message is displayed along with a partial listing of the options accepted by cool .

The filename arguments specify a list of input files that are to be prelinked. You must specify the complete name of the file; cool does not assume a .o extension.

The SAS/C C library objects are located in the ar370 archive /libdir/ libc.a . The libdir depends on where the product was installed and which target you are compiling for. The SAS/C C++ objects are located in the ar370 archive /libdir/ libcxx.a . In order to resolve references to SAS/C C and C++ library functions, these ar370 archives must be included in the cool command. If you are prelinking a C++ program, you must specify /libdir/ libcxx.a before specifying /libdir/ libc.a .

Examples

The following examples are command line invocations of cool :

cool -o prog alpha.o beta.o / libdir /libc.a
Prelink the object files alpha.o and beta.o to produce the prelinked output file prog .

libc.a must be included in order to resolve references to SAS/C C library functions. The directory specification, libdir, for this library is target and site-specific. If you are not sure where it is located at your site, compile a program with the -v (verbose) option to see the default command line used by the sascc370 or sasCC370 compiler driver to invoke cool .

cool -o prog myojb.o / libdir /libcxx.a / libdir /libc.a
In this example, a C++ object file, myojb.o , is being prelinked, generating the prelinked output file prog .

Note:    If you are using cool to prelink a C++ program, you must specify /libdir/ libcxx.a before specifying /libdir/ libc.a . The SAS/C C++ library functions must be resolved before SAS/C C library functions. The directory specification, libdir, for this library is site-specific. If you are not sure where it is located at your site, compile a program with the -v (verbose) option to see the default command line used by the sascc370 or sasCC370 compiler driver to invoke cool .  [cautionend]

cool -o prog interface.o io_handler.o / libdir /libares.a
In this example, the all-resident library, libares.a , is specified. Specialized applications, such as all-resident or SPE applications, must be linked with special library routines. See Library Files and the SAS/C Compiler and Library User's Guide for more information.

cool -o prog -w binary_tree.o / libdir /libc.a
Prelink the object file binary_tree.o , generating the prelinked output file prog . The -w option specifies that warning messages should be suppressed.


Using COOL on the Mainframe

The other method of prelinking your object files is to copy them to the mainframe where they can be linked with the COOL object code utility. The SAS/C Compiler and Library User's Guide describes the COOL CLIST and the COOL EXEC , which can be used to invoke COOL on the mainframe.

Note:    You can use the UNIX cat command or the DOS copy /b command to combine multiple object files into a single file on the workstation, copy that file to the mainframe, and then run COOL on the mainframe on the copied file. This is often easier than copying each file individually.  [cautionend]

Also note that if you use extended names or the -Aprem option, you should not prelink both on the workstation and on the mainframe.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.