Make a Library from Several Classes

In our course at Duke, we put all the "major" classes used in our courses (e.g., string, vector, etc.) into one library. We then supply a generic makefile that can be used with any single-file program that automatically looks in the right place for header files and links in the implementations stored in the library.

The examples below show what we use to generate/update the library and the generic makefile. This works on Unix systems. I hope to include informatino about making libraries in other environments as it is available. If anyone has done this, please let me know.


Compiling a Library

To make a library (.a) file on Unix machines use the Makefile here.

Generic Makefile

To compile any .cc (or your favorite suffix, e.g., .cpp) into a corresponding executable use this Makefile . This means a file foo.cc will generate an executable foo. For multiple file projects you'll need to provide rules for the Makefile.