12

For another universal library I need to combine 2 existing dylibs (here x86 and x64) into a single universal lib. How can I do that without re-building the existing libraries?

7
  • @trojanfoe: Can you elaborate a little? Won't libtool work?
    – Toastor
    Apr 1, 2014 at 11:10
  • No, it's the same a decomposing a binary executable. Once the linker has done its work, relocating, dumping unused functions, etc, it's very difficult (impossible?) to get it back to something you can re-link. The only real option is to have the object files and create the .dylib using them. However it's not clear why having 2 .dylibs is such a big deal in the first place...
    – trojanfoe
    Apr 1, 2014 at 11:12
  • @trojanfoe The reasons for combining dylibs set aside - shouldn't it be possible (in theory) to just append one dylib to the other and to merge the symbol tables (applying offsets to the symbols)? I have only a basic understanding of how dylibs are structured, so forgive me if I sound silly. I'm here to learn :)
    – Toastor
    Apr 1, 2014 at 11:57
  • I very much doubt it. The tools just don't exist to do this as there is (normally) no need for it.
    – trojanfoe
    Apr 1, 2014 at 12:20
  • @trojanfoe yes, I'm aware that there probably are no such tools. I meant to ask if it is possible in theory - if one would be able to create such a tool, disregarding whether that would actually make any sense. I'm just trying to expand my understanding of the inner workings of libraries and frameworks currently. Can you recommend some good reading on the matter?
    – Toastor
    Apr 1, 2014 at 12:36

1 Answer 1

23

Actually, it's extremely easy to do once you know it. There's a tool called lipo that can do a number of things with dylibs. One is to combine two (or more) libraries. For example:

lipo lib1.dylib lib2.dylib -output combined.dylib -create

where lib1 could be an i386 and lib2 an x86_64 arch type. It will create a dylib in the local folder containing both archs.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.