I got the same issue than How to create one static library from several others static libraries in C on Linux?
The answer worked for me when I did manually, but how to automatize this with a Makefile ? My current rule is:
$(STATIC_LIB_TARGET): $(LIB_OBJS) $(THIRDPART_LIBS)
$(Q)cd $(BUILD) && $(AR) $(ARFLAGS) $@ $(LIB_OBJS) && ranlib $@
$(STATIC_LIB_TARGET)
is my static lib I want to create, $(LIB_OBJS)
contains my project .o
files inside my output folder $(BUILD)
and $(THIRDPART_LIBS)
contains the list of external .a
that I have to ar -x
. My issue is that ar -x
shall be called for each static lib and cannot be grouped and the list of extracted .o files shall be got into Makefile variable.
I could use foreach
over $(THIRDPART_LIBS)
or call shell script, but this seems complicated. I think a more elegant solution exists.
Thanks in advance.