Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to create pass-through (stub) dylib without using flat namespaces?



I need to create a dylib (A) that links to another dylib (B) such that linking to A is sufficient to get the symbols of B (without linking directly to B).
i.e. something like this:
B.c:
void foo1() {... };
void foo2() {... };
[...]
gcc -dynamiclib -o libB.dylib B.c


A.c:
void dummy() { foo1(); foo2(); ... }
[just to make sure all symbols are there - could be empty, too]
gcc -dynamiclib -o libA.dylib A.c -L. -lB

prog.c:
int main(int argc, char **argv) {
foo1();
return 0;
}
gcc -o prog prog.c -L. -lA

As-is it won't work, because the symbols in libB are visible only to libA and not to the prog. So I need some way to make all symbols in B exported through A. I cannot use flat name space - so please discard that right away. In fact I cannot change any flags of prog, so using - undefined dynamic_lookup for prog is not an option, either.

I know that a solution exists, because that is what Apple's frameworks do if they have sub-frameworks or libs (e.g. have a look at vecLib - it contains no symbols itself but collects all symbols of the libraries it is linked to) and they use two-level namespaces. This is exactly what I need. I couldn't find anything in ld/gcc/dyld, though.

Any help is highly appreciated.

Thanks,
Simon



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.