[prog] C++ Inheritance

Elizabeth Barham lizzy at soggytrousers.net
Sat May 24 04:06:44 EST 2003


Mary writes:

> Incidently, the reason you can make object files and link them all
> together later is this: imagine you have a project that takes 12
> hours to compile. You change 1 line. You wish to test it. Instead of
> doing the entire 12 hour compile again, you recompile that file into
> an object file, and then do the linking step with all the other
> object files that are unchanged from old compiles.

   Also, object files are what make up static libraries. If you check
out the "ar" command you'll discover that its simply an archiver in
the same manner as the famous "tar" program, "tape archiver". ar has
an option (s) that generates a symbol table which helps speed up the
linking step.

   But, in general, a static library is simply a collection of these
object files run together with "ar". By naming the library "libX.a",
then one may link against it using the -lX option of the various
binutils (gcc, g++, ld, etc) and use the functions and/or classes
defined therein.

   Ideally, an object file is a self-contained little chunk of object
code (raw code to feed into the CPU) that represents some
understandable, bite-size tidbit of a larger concept, whether it be a
series of functions to render images or C++ classes that encapsulate
images. By concatenating the little pieces of object code together
into a library, the whole, larger concept is compartmentalized and
neatly tucked away for later use. When we have need of it, we simply
tell the linker about it and it pulls in the needed object code and
delivers the final executable.

   A great deal of computer science is the abstraction of the nuts and
bolts of the CPU. By envisioning things as say, objects, functions or
libraries, we can work with them easier and better. And as the
technology grows and we work on larger and more difficult projects,
the abstractions no longer are nice-ities but rather necessities.

Elizabeth


More information about the Programming mailing list