Problem loading a dylib file through LOAD-FOREIGN-FUNCTION

Robert P. Goldman rpgoldman at sift.info
Sun Aug 25 14:34:16 UTC 2013


Luís Oliveira wrote:
> On Sun, Aug 25, 2013 at 3:46 AM, Robert P. Goldman <rpgoldman at sift.info> wrote:
>>         /usr/local/lib/libsmvgrammar.0.dylib: mach-o, but wrong filetype.
>>
>> If this had said "wrong architecture", I would have guessed that this
>> was a 32bit/64bit mismatch.  But "wrong filetype" seems to indicate a
>> different error, and one that I haven't had any luck googling.  At any
>> rate, I have checked and I have x86_64 SBCL and x86_64 dylibs.
> 
> I've never come across this either. What does the "file" command have
> to say about libsmvgrammar.0.dylib?  Also, what happens when you try
> to foreign load that?
> 
> Cheers,
> 

I get the same error:
Unable to load foreign library (LIBSMVGRAMMAR.0.DYLIB-1099).
  Error opening shared object "libsmvgrammar.0.dylib":
  dlopen(libsmvgrammar.0.dylib, 10): no suitable image found.  Did find:
	/usr/local/lib/libsmvgrammar.0.dylib: mach-o, but wrong filetype.
   [Condition of type LOAD-FOREIGN-LIBRARY-ERROR]


Here's some more information:

 $ otool -f /usr/local/lib/libsmvgrammar.0.dylib
Fat headers
fat_magic 0xcafebabe
nfat_arch 1
architecture 0
    cputype 16777223
    cpusubtype 3
    capabilities 0x0
    offset 4096
    size 38332
    align 2^12 (4096)

$ lipo -detailed_info /usr/local/lib/libsmvgrammar.0.dylib
Fat header in: /usr/local/lib/libsmvgrammar.0.dylib
fat_magic 0xcafebabe
nfat_arch 1
architecture x86_64
    cputype CPU_TYPE_X86_64
    cpusubtype CPU_SUBTYPE_X86_64_ALL
    offset 4096
    size 38332
    align 2^12 (4096)

$ file /usr/local/lib/libsmvgrammar.0.dylib
/usr/local/lib/libsmvgrammar.0.dylib: Mach-O universal binary with 1
architecture: [x86_64: Mach-O 64-bit x86_64 dSYM companion file]

BTW. these results are from after I used lipo -create on the original
file: I was concerned that the file might not be working because it was
a thin file instead of a fat file.  But "fattening" it seems to make no
difference.

I have seen a couple of mentions of this filetype error in google, but
only in contexts where someone works around it -- in no place do I see a
definition of what this error string is intended to mean (unlike the
"wrong architecture" one), including on the Apple Developer list.

I was able to load libaspell.dylib, so I don't think it's that my
machine is hopelessly messed up.  For that library I see, by contrast

$ lipo -detailed_info libaspell.dylib
Fat header in: libaspell.dylib
fat_magic 0xcafebabe
nfat_arch 4
architecture ppc
    cputype CPU_TYPE_POWERPC
    cpusubtype CPU_SUBTYPE_POWERPC_ALL
    offset 4096
    size 1961296
    align 2^12 (4096)
architecture i386
    cputype CPU_TYPE_I386
    cpusubtype CPU_SUBTYPE_I386_ALL
    offset 1966080
    size 1506276
    align 2^12 (4096)
architecture ppc64
    cputype CPU_TYPE_POWERPC64
    cpusubtype CPU_SUBTYPE_POWERPC_ALL
    offset 3473408
    size 2058888
    align 2^12 (4096)
architecture x86_64
    cputype CPU_TYPE_X86_64
    cpusubtype CPU_SUBTYPE_X86_64_ALL
    offset 5533696
    size 1714136
    align 2^12 (4096)

This seems to be a dlopen error, not something that's wrong with CFFI --
I was just hoping someone here would know.

Cheers,
r



More information about the cffi-devel mailing list