Building Libraries

just use -o library_file_name

Tutorials


Introduction   

Building   

Multiple Libraries   

 

Modifying   

Recognized Library Extensions   

 
 

Introduction

We taught the compiler how to build and modify object libraries. We did this for two reasons:

  1. The process of building a library containing C++ templates or initialized global objects is significantly more complex than the process of building a library for C and Fortran.
  2. The process of building shared libraries varies significantly from one platform to another.

If you think of the library as an executable program, then the method of building the library should be intuitive. Just use the -o xxx command line option, substituting the library file name for xxx.


How to Build a Library

To build a static library named my_library.a containing the objects a.o, b.o and c.o, use these compiler command line options:

    UCC -o my_library.a  a.o  b.o c.o

To build a shared library, use a similar command, but change the extension used in the library file name from .a to the appropriate extension for your system.


How to Modify a Library

To modify a static library named my_library.a containing the objects a.o, b.o and c.o, by replacing the file a.o and adding the object d.o, use these compiler command line options:

    UCC -o my_library.a  a.o d.o my_library.a

At present, there is not a way to modify a shared library. You have to rebuild it from scratch.


Dealing with Multiple Libraries

If you wish to create a library that uses the contents of another library, but does not contain it, then simply add used library to the command line arguments, just as you would if you were building an executable. To build a static library this_library.a containing the objects aa.o, bb.o and cc.o, each of which use files from my_library.a, use these compiler command line options:

    UCC -o this_library.a  aa.o bb.o cc.o my_library.a

To build a shared library, use a similar command, but change the extension used in the library file name from .a to the appropriate extension for your system.


Recognized Library Extensions

   Library Type 
 Platform   static   shared 
HP-UX .a .sl
 All Other Unix  .a .so


Need Help? Contact Technical Support

Copyright © 1997-1998. All rights reserved.