문제

ar can create an .a file which includes another .a file, such that the output of ar -t whatever.a looks like:

someotherarchive.a
foo.o
bar.o

However, if this archive is then linked, the symbols from an .o in someotherarchive.a will not be accessible by foo.o. This can be resolved by flattening with the T switch to ar when creating, but that also creates a thin archive. Since there does not seem to be a flatten-but-don't-thin option, it's necessary to extract from someotherarchive.a first and then link the .os independently to create something that contains:

otherarchivememberA.o
otherarchivememberB.o
foo.o
bar.o

Raising the question, if putting one .a inside another .a makes it inaccessible, what's the purpose of doing so?

도움이 되었습니까?

해결책

Presumably this is because ar was historically a general purpose archiving tool, like tar.

In other words, there is no purpose to inaccessibly nesting archives if you are creating static libraries.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top