unix - ar on an existing .a file? -
essentially, want this:
gcc foo.c -o foo.o ar rcs foo.a foo.o gcc bar.c -o boo.o ar rcs bar.a bar.o foo.a
i want archive both object , static library static library. unfortunately, last command doesn't end containing foo.o (it contains bar.o , foo.a), when linking stage, linker can't find symbols foo.o.
is there way want here? i'm doing of out of make, i'm looking solution doesn't involve extracting & re-archiving objects (which seems kinda painful). there way make kind of "archive archive" setup work?
actually, not want archive 1 whole '.a' file inside another. might want archive members of 1 archive in other - wholly different operation.
the 'ar' program capable of storing source files, gzipped tar files, html files, xml files, , pretty other type of file in '.a' (and '.a' suffix conventional, not mandatory) -- try time. however, treats object files (and object files) specially, , makes them available use linker ('ld'), linker uses such files if extension '.a'.
so, want have 2 libraries:
foo.a
containingfoo.o
bar.a
containingbar.o
, objectsfoo.a
short of doing suggest , extracting objects foo.a
, building them bar.a
, alternative list members of foo.a
members of bar.a
too:
foo_objs = foo.o bar_objs = bar.o $(foo_objs) foo.a: $(foo_objs) $(ar) $(arflags) $@ $(foo_objs) bar.a: $(bar_objs) $(ar) $(arflags) $@ $(bar_objs)
i assuming example minimized. if not, why bother 2 libraries. uses code foo.o link foo.o if given bar.a link with. (it different if these shared objects, still better use 1 rather 2 shared objects.)
Comments
Post a Comment