OT (maybe) How to create a library of libraries

Robert S. Grimes rsg at alum.mit.edu
Tue Aug 21 14:16:04 CDT 2007

This might be a bit off-topic, but because I'm trying to use the RTEMS
build system, perhaps not completely?  :-)

Anyway, I have a series of libraries, one per functional module) that I
want to use for several RTEMS apps.  I originally used this setup for
the libraries, using the RTEMS Templates/Makefile.dir and
Templates/Makefile.lib templates

  projectroot/libs/Makefile    -- a simple RTEMS directory Makefile
  projectroot/libs/first            -- a simple RTEMS library Makefile
    . . .

Then my application Makefile (again based on an RTEMS Template) has this
fragment in it:

  MYLIBS = ../../lib/first/${ARCH}/libfirst.a
    . . .
  MYLIBS += ../../lib/last/${ARCH}/liblast.a

And the app is linked like this:


Works just fine, of course.  But the problem is that the number of
libraries is growing, and I'm getting tired of modifying all my
application Makefiles (okay, just one right now, but that's changing
soon) every time I create a new library.  What I want is to create on
"super-library" that contains all the module libraries.  So now my
application Makefiles would simple have this definition:

  # New (2007/08/21) unified EPP library
  MYLIBS += ../../lib/uberlib/${ARCH}/libuberlib.a

So I created a new library (in projectroot/libs/uberlib) that has
another Makefile.lib-based Makefile, except instead of putting object
files into the output library, it puts the other libraries.  I've almost
got this all working; I indeed have my "uber library" (please excuse any
language errors in my attempt to be witty).  Problem comes when I try to
link my application, I get an error like this:

  make[1]: Entering directory `/Home/development/apps/master/main'
  powerpc-rtems-g++ -B/usr/rtems/
$(OPTS) \
  -o o-optimize/MyApp.exe ${OBJS) $(OTHERLIBS)
  ../../lib/epp/o-optimize/libepp.a: could not read symbols: Archive has
no index; run ranlib
  to add one
  collect2: ld returned 1 exit status
  make[1]: *** [o-optimize/MyApp.exe] Error 1
  make[1]: Leaving directory `/Home/development/apps/master/main'
  make: *** [all] Error 1

But of course, ranlib was run on each of the "sublibs", and again on the
"uberlib".  I tried running it again, and also not running it on the
sublibs - just the uberlib - but always the same error.  Am I missing
something?  Or more accurately, what am I missing?


More information about the rtems-users mailing list