I have been maintaining a libjpeg and libpng package installer for OS X, mainly for portability with packages which expect to find jpeg or png headers in one of the standard include directories...
Anyway, I've been trying to do a 4-way universal build on 10.5. E.g., -arch i386 -arch x86_64 -arch ppc -arch ppc64, plus I've tried a various combinations of sdk options like -mmacosx-version-max=10.4, -universal, -isysroot. The library builds fine, and I can link against it on Leopard, but when I try to link against it on 10.4 (with Xcode 2.5, gcc version 4.0.1 build 5370), I get the following error: /Developer/usr/bin/../libexec/gcc/i686-apple-darwin8/4.0.1/ld: /usr/local/lib/libjpeg.dylib load command 7 unknown cmd field collect2: ld returned 1 exit status
If I delete the dynamic library, it will link and launch using the static library. So this is something specific to the dynamic library.
On further investigation (otool -l /usr/local/lib/libjpeg.dylib), load command 7 in the dylib is: Load command 7 cmd ?(0x0000001e) Unknown load command cmdsize 16 000233e8 0000014c (full otool output attached at end)
Command 0x1e is sure enough not found in /usr/include/mach-o/loader.h on 10.4, however, this command corresponds to 'LC_SEGMENT_SPLIT_INFO':
So my current theory is that I'm compiling the code properly, as it will link/load/execute statically, but either not generating the shared library properly, not linking the executable against the library properly, or have uncovered a bug in the linker.
Evidence for the last is that the cmd is '0x0000001e', NOT '0x8000001e'; in other words, the LC_REQ_DYLD flag is not set, so I think the linker should simply be ignoring the unknown command instead of barfing. (see comments in mach-o/loader.h)
Thoughts? I couldn't find any information on the mystery command LC_SEGMENT_SPLIT_INFO, in particular how to disable it or if it's actually necessary.
thanks! -ethan
|