Loading libraries on OSX

Started by methodic, January 01, 2011, 10:44:17 AM

Previous topic - Next topic

methodic

Running Snow Leopard, latest version of NewLISP. Trying to use the memcached.lsp file, but NewLISP is having trouble importing the library which was installed via macports:
> (import "/opt/local/lib/libmemcached.5.dylib" "memcached_create")

ERR: problem loading library in function import : "dlopen(/opt/local/lib/libmemcached.5.dylib, 9): no suitable image found.  Did find:nt/opt/local/lib/libmemcached.5.dylib: mach-o, but wrong architecture"


I didn't build libmemcached with any special arguments, just "port install libmemcached".



Any tips/ideas? Thanks in advance.

Lutz

#1
Make sure that both, the library and newLISP are either both 32-bit or both 64-bit. And of course memcached.lsp must have been written the correct way too. Most modules in newlis-x.x.x/modules (/usr/share/newlisp/modules/ when installed) are written to run with both 32-bit and 64-bit architectures of libraries and newLISP executable, but I have no info regarding memcached.lsp. Some modules run on both architectures out of the box, others need fixes. In any case, always the newLISP executable and the imported library must have the same bitness.



When Mac OS X went from Leopard to Snow Leopard. Apple went from 32-bit default compiles to 64-bit default compiles when using GCC. Because of this, some libs stopped working, e.g. the stock libgmp.dylib went from 32-bit to 64-bit and you have to recompile either libgmp.dylib to 32-bit or newLISP to 64-bit, to run it.



newLISP's standard installers are all 32-bit.

methodic

#2
Ah, thanks Lutz, good catch. It indeed was a 32bit vs 64bit issue.



Hope you had a happy new years!



-Tony.