Loading libraries on OSX

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
methodic
Posts: 58
Joined: Tue May 10, 2005 5:04 am

Loading libraries on OSX

Post by 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:

Code: Select all

> (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:\n\t/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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Loading libraries on OSX

Post by Lutz »

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
Posts: 58
Joined: Tue May 10, 2005 5:04 am

Re: Loading libraries on OSX

Post by methodic »

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

Hope you had a happy new years!

-Tony.

Locked