Finding module names to call libc functions using FFI
Jason Rogers
jacaetevha at fast-mail.org
Thu Mar 3 21:05:38 UTC 2005
Ned Konz wrote:
>I've made UnixShell as a subclass of ExternalObject.
>
>It has one method:
>
>system: aString
> <cdecl: long 'system' (char *) module: 'c.so.6'>
> ^self externalCallFailed.
>
>
>This works fine. HOWEVER... note the 'c.so.6'. This refers to /lib/libc.so.6,
>which is a symlink to another .so file in /lib. These arguments work fine
>too:
>
>'libc.so.6'
>'/lib/libc.so.6'
>
>But I'd really like to use just 'c' or 'libc' instead, because (obviously) the
>version of the .so file on my system may not be the named the same as yours.
>
>I have also tried (without success):
>* using '' as a module name (hoping to get the version linked into my Squeak
>executable, if any)
>* using the full name of my Squeak VM
>* making an ExternalLibraryFunction with a nil module
>
>Does anyone know a more universal way to get this information? Lookup table
>keyed by platform name (ick)?
>
>Thanks,
>
>
I may be speaking out of FFI ignorance, but here goes...
While it's not an elegant solution couldn't you get a listing of files
in /lib and "figure out" which one to use? Wouldn't the pattern would
always be (pardon the RegEx) "\/lib\/libc\.so(\.[0-9]+){0,2}"?
--
Jason Rogers
"I am crucified with Christ: nevertheless I live; yet not I,
but Christ liveth in me: and the life which I now live in
the flesh I live by the faith of the Son of God, who loved
me, and gave himself for me."
Galatians 2:20
More information about the Squeak-dev
mailing list
|