Creating a shared library with the makeC++SharedLib utility

makeC++SharedLib is a shell script that links C++ .o and .a files. It can be redistributed and used by someone who does not have XL C/C++ installed.

It is recommended that you use the -qmkshrobj compiler option instead of the makeC++SharedLib command. Among the advantages to using this option are the automatic handling of link-time C++ template instantiation (using either the template include directory or the template registry), and compatibility with the -O5 option.

Read syntax diagramSkip visual syntax diagram
makeC++SharedLib command syntax

               .------------------------------.   
               V                              |   
>>-invocation----+---------+--+-------------+-+----------------><
                 '-options-'  '-input_files-'     

invocation
Is the command, preceded by the path. The following commands are provided:
  • makeC++SharedLib
  • makeC++SharedLib_r
  • makeC++SharedLib_r7
  • makeC++SharedLib128

You can specify one or more of the following options:

-o shared_file.o
The name of the file that will hold the shared file information. The default is shr.o.
-b
Uses the -b binder options of the ld command.
-Llib_dir
Uses the -L option of the ld command to add the directory lib_dir to the list of directories to be searched for unresolved symbols.
-llibrary
Adds library to the list of libraries to be searched for unresolved symbols.
-p priority
Specifies the priority level for the file. priority can be any number from -214782623 (highest priority-initialized first) to 214783647 (lowest priority-initialized last). Numbers from -214783648 to -214782624 are reserved for system use. For more information, see Assigning priorities to objects.
-I import_list
Uses the -bI option of the ld command to resolve the list of symbols in the file import_list that can be resolved by the binder.
-E export_list
Uses the -bE option of the ld command to export the external symbols in the export_list file. If you do not specify -E export_list, a list of all global symbols is generated.
-e file
Saves in file the list computed by -E export_list.
-n name
Sets the entry name for the shared executable to name. This is equivalent to using the command ld -e name.
-w
Excludes weak symbols from being exported.
-X mode
Specifies the type of object file makeC++SharedLib should create. The mode must be either 32, which processes only 32-bit object files, or 64, which processes only 64-bit object files. The default is to process 32-bit object files (ignore 64-bit objects). You can also set the mode with the OBJECT_MODE environment variable. For example, OBJECT_MODE=64 causes makeC++SharedLib to process any 64-bit objects and ignore 32-bit objects. The -X flag overrides the OBJECT_MODE variable.

The input files can be any of the following:

file.o
Is an object file to be put into the shared library.
file.a
Is an archive file to be put into the shared library.
The following table shows equivalent options between makeC++SharedLib and -qmkshrobj:
makeC++SharedLib options -qmkshrobj and related options
-p nnn -qmkshrobj=nnn
-e file_name -qexpfile=file_name
-E export_file -bE:export_file
-I export_file -bI:export_file
-x -qnolib
-x 32 -q32
-x 64 -q64
-n entry_point -e entry_point
-w -qnoweakexp