If you want to use the
libmass.a scalar
library for some functions and the normal math library
libm.a for
other functions, follow this procedure to compile and link your program:
- Create an export list (this can be a flat text file) containing
the names of the desired functions. For example, to select only the
fast tangent function from libmass.a for use with the C program sample.c,
create a file called fasttan.exp with the following line:
tan
- Create a shared object from the export list with the ld command,
linking with the libmass.a library. For example:
ld -bexport:fasttan.exp -o fasttan.o -bnoentry -lmass -bmodtype:SRE
- Archive the shared object into a library with the ar command.
For example:
ar -q libfasttan.a fasttan.o
- Create the final executable using xlc, specifying the object file containing
the MASS functions before the standard math library, libm.a.
This links only the functions specified in the object file (in this
example, the tan function) and the remainder of the
math functions from the standard math library. For example:
xlc sample.c -o sample -Ldir_containing_libfasttan -lfasttan -lm
Notes: - The MASS sincos function is automatically linked
if you export MASS cosisin;
- The MASS cos function is automatically linked
if you export MASS sin;
- The MASS atan2 is automatically linked if you
export MASS atan.
Related external information - ar and ld in the AIX Commands Reference, Volumes 1 -
6