How to determine if an OS X dylib was linked with -flat_namespace
Asked Answered
S

1

3

I have a third party OS X dylib that I'm using in my app and don't have easy access to its creator. I'd like to determine if it was linked with -flat_namespace. Is that possible? If so, how?

Sophistic answered 31/3, 2010 at 13:59 Comment(0)
B
12

Run otool -hV on the library. If you don't see TWOLEVEL, then it was linked with -flat-namespace. For example:

twolevel.dylib:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL  0x00       DYLIB     8        672   NOUNDEFS DYLDLINK TWOLEVEL NO_REEXPORTED_DYLIBS

versus

flat.dylib:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL  0x00       DYLIB     8        672 DYLDLINK NO_REEXPORTED_DYLIBS
Bergstein answered 2/4, 2010 at 0:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.