User`s guide

Compiler Overview [7]
7.7 Creating New Libraries
You can create a user-defined library in the same way that you build a program in
whole-program mode. To do this, use the -R option to suppress the creation of an
executable.
For example, to build the library tinyblas.a from functions in the files ddot.cc
and dgemv.cc, use the following sequence of commands.
c++ -pl tinyblas.a -c ddot.cc dgemv.cc
c++ -pl tinyblas.a -R ddot.o dgemv.o
In the previous example, the first command creates the initial program library, checks
the two source files for syntax errors, and copies them into the program library. The
second command finishes compilation of the functions in ddot and dgemv with
inlining enabled between files and from the standard libraries. The -R flag directs
the compiler to place the generated relocatable object code in the program library and
suppresses the build of an executable.
The following sequence of commands provides the same results:
c++ -pl tinyblas.a -c ddot.cc
c++ -pl tinyblas.a -c dgemv.cc
c++ -pl tinyblas.a -R ddot.o dgemv.o
Or, you can use the following single command:
c++ -pl tinyblas.a -R ddot.cc dgemv.cc
You can update a library with an incremental compilation. To do this, use the
following sequence of commands.
c++ -pl tinyblas.a -R ddot.cc dgemv.cc
edit dgemv.cc
c++ -pl tinyblas.a -R ddot.cc dgemv.cc
In the previous example, the first compile creates the library as usual. The second
compile examines ddot.cc (and ignores it because it remains unchanged) and
then focuses on dgemv.cc , which has presumably been changed by the edit. The
compiler recompiles any modified function in dgemv.cc and any function that
depends on a changed function (perhaps because of inlining). The rest of the library
remains the same.
There is no requirement that a library end with an .a suffix. The inclusion of the -R
flag in a separate-module compilation line enables inlining from the standard libraries
into the newly created library. The library looks like a traditional (fat) object file.
S247920 87