* FFI on OS X? @ 2011-03-02 20:07 Michael Ellis 2011-03-02 20:23 ` Hans Aberg 2011-03-02 21:22 ` Andy Wingo 0 siblings, 2 replies; 9+ messages in thread From: Michael Ellis @ 2011-03-02 20:07 UTC (permalink / raw) To: bug-guile Trying to follow the examples in section 6.20.6 in the manual I get the following. scheme@(guile-user)> (define libm (dynamic-link "/usr/lib/libm.dylib")) ERROR: In procedure dynamic-link: file: "/usr/lib/libm.dylib", message: "file not found" The same library can be loaded and its functions are available with python ctypes, e.g. >>> libm=CDLL("/usr/lib/libm.dylib") >>> libm <CDLL '/usr/lib/libm.dylib', handle 7fff5fc43d68 at 1004dfc50> >>> libm.j0 <_FuncPtr object at 0x100599d50> What am I doing wrong? Thanks, Mike ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: FFI on OS X? 2011-03-02 20:07 FFI on OS X? Michael Ellis @ 2011-03-02 20:23 ` Hans Aberg 2011-03-02 21:22 ` Andy Wingo 1 sibling, 0 replies; 9+ messages in thread From: Hans Aberg @ 2011-03-02 20:23 UTC (permalink / raw) To: Michael Ellis; +Cc: bug-guile On 2 Mar 2011, at 21:07, Michael Ellis wrote: > Trying to follow the examples in section 6.20.6 in the manual I get > the following. > > scheme@(guile-user)> (define libm (dynamic-link "/usr/lib/libm.dylib")) > ERROR: In procedure dynamic-link: file: "/usr/lib/libm.dylib", > message: "file not found" ... > What am I doing wrong? Guile, or what it uses to load libraries, assumes that a dynamic library ends in something else than ".dylib". Make a soft link ('ln -s') ending in ".so", and load this instead, and it will work. Hans ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: FFI on OS X? 2011-03-02 20:07 FFI on OS X? Michael Ellis 2011-03-02 20:23 ` Hans Aberg @ 2011-03-02 21:22 ` Andy Wingo 2011-03-02 22:15 ` Hans Aberg 1 sibling, 1 reply; 9+ messages in thread From: Andy Wingo @ 2011-03-02 21:22 UTC (permalink / raw) To: Michael Ellis; +Cc: bug-guile On Wed 02 Mar 2011 21:07, Michael Ellis <michael.f.ellis@gmail.com> writes: > scheme@(guile-user)> (define libm (dynamic-link "/usr/lib/libm.dylib")) > ERROR: In procedure dynamic-link: file: "/usr/lib/libm.dylib", > message: "file not found" What if you leave off the suffix? scheme@(guile-user)> (use-modules (system foreign)) scheme@(guile-user)> (dynamic-link "libm") $1 = #<dynamic-object "libm"> Guile uses libltdl, which does this sort of thing. Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: FFI on OS X? 2011-03-02 21:22 ` Andy Wingo @ 2011-03-02 22:15 ` Hans Aberg 2011-03-03 9:25 ` Andy Wingo 0 siblings, 1 reply; 9+ messages in thread From: Hans Aberg @ 2011-03-02 22:15 UTC (permalink / raw) To: Andy Wingo; +Cc: bug-guile On 2 Mar 2011, at 22:22, Andy Wingo wrote: > What if you leave off the suffix? > > scheme@(guile-user)> (use-modules (system foreign)) > scheme@(guile-user)> (dynamic-link "libm") > $1 = #<dynamic-object "libm"> That does not work for me. scheme@(guile-user)> (dynamic-link "libm") ERROR: In procedure dynamic-link: ERROR: In procedure dynamic-link: file: "libm", message: "file not found" > Guile uses libltdl, which does this sort of thing. Yes, that is the problem, I think. I saw it on the Bessel-function example in the manual, and reported it before. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: FFI on OS X? 2011-03-02 22:15 ` Hans Aberg @ 2011-03-03 9:25 ` Andy Wingo 2011-03-03 9:48 ` Hans Aberg 0 siblings, 1 reply; 9+ messages in thread From: Andy Wingo @ 2011-03-03 9:25 UTC (permalink / raw) To: Hans Aberg; +Cc: bug-guile On Wed 02 Mar 2011 23:15, Hans Aberg <haberg-1@telia.com> writes: > scheme@(guile-user)> (dynamic-link "libm") > ERROR: In procedure dynamic-link: > ERROR: In procedure dynamic-link: file: "libm", message: "file not found" Why does this fail? Can you strace it? What version of libltdl do you have? Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: FFI on OS X? 2011-03-03 9:25 ` Andy Wingo @ 2011-03-03 9:48 ` Hans Aberg 2011-03-03 14:36 ` Andreas Rottmann 0 siblings, 1 reply; 9+ messages in thread From: Hans Aberg @ 2011-03-03 9:48 UTC (permalink / raw) To: Andy Wingo; +Cc: bug-guile On 3 Mar 2011, at 10:25, Andy Wingo wrote: > On Wed 02 Mar 2011 23:15, Hans Aberg <haberg-1@telia.com> writes: > >> scheme@(guile-user)> (dynamic-link "libm") >> ERROR: In procedure dynamic-link: >> ERROR: In procedure dynamic-link: file: "libm", message: "file not found" > > Why does this fail? Can you strace it? If you tell me how. :-) However, it works, also full path, with or without file name extension, as long as the name of the library actually opened ends in .so. If it ends in .dylib, it says it is not found. > What version of libltdl do you > have? libltdl.7 from libtool-2.4. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: FFI on OS X? 2011-03-03 9:48 ` Hans Aberg @ 2011-03-03 14:36 ` Andreas Rottmann 2011-03-03 16:53 ` Michael Ellis 0 siblings, 1 reply; 9+ messages in thread From: Andreas Rottmann @ 2011-03-03 14:36 UTC (permalink / raw) To: Hans Aberg; +Cc: bug-guile Hans Aberg <haberg-1@telia.com> writes: > On 3 Mar 2011, at 10:25, Andy Wingo wrote: > >> On Wed 02 Mar 2011 23:15, Hans Aberg <haberg-1@telia.com> writes: >> >>> scheme@(guile-user)> (dynamic-link "libm") >>> ERROR: In procedure dynamic-link: >>> ERROR: In procedure dynamic-link: file: "libm", message: "file not found" >> >> Why does this fail? Can you strace it? > > If you tell me how. :-) > Apparently, on OS X, "dtruss" does fulfill the role of "strace": <http://humberto.digi.com.br/blog/2008/02/25/strace-on-mac-os-x-leopard/>. HTH, Rotty -- Andreas Rottmann -- <http://rotty.yi.org/> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: FFI on OS X? 2011-03-03 14:36 ` Andreas Rottmann @ 2011-03-03 16:53 ` Michael Ellis 2011-03-03 19:49 ` Andy Wingo 0 siblings, 1 reply; 9+ messages in thread From: Michael Ellis @ 2011-03-03 16:53 UTC (permalink / raw) To: Andreas Rottmann; +Cc: bug-guile On Thu, Mar 3, 2011 at 9:36 AM, Andreas Rottmann <a.rottmann@gmx.at> wrote: > Hans Aberg <haberg-1@telia.com> writes: >>> Why does this fail? �Can you strace it? >> >> If you tell me how. :-) >> > Apparently, on OS X, "dtruss" does fulfill the role of "strace": > <http://humberto.digi.com.br/blog/2008/02/25/strace-on-mac-os-x-leopard/>. Thanks for the tip about dtruss. Very useful to know about. For the record, here's some dtruss output created when I try to dynamic-link a library that doesn't have a .so softlink, ie (dynamic-link "libf77lapack"). As you can see it's trying 'open_nocancel', 'access', and 'stat64' looking for .la and .so in all all the right places before giving up. 89795/0x1bfacf: open_nocancel("/usr/local/lib/libf77lapack.la\0", 0x0, 0x1B6) = -1 Err#2 89795/0x1bfacf: open_nocancel("/usr/local/lib/libf77lapack.la\0", 0x0, 0x1B6) = -1 Err#2 89795/0x1bfacf: open_nocancel("/lib/libf77lapack.la\0", 0x0, 0x1B6) = -1 Err#2 89795/0x1bfacf: open_nocancel("/usr/lib/libf77lapack.la\0", 0x0, 0x1B6) = -1 Err#2 89795/0x1bfacf: open_nocancel("libf77lapack.la\0", 0x0, 0x1B6) = -1 Err#2 89795/0x1bfacf: access("/usr/local/lib/libf77lapack.so\0", 0x4, 0x10060A800) = -1 Err#2 89795/0x1bfacf: access("/usr/local/lib/libf77lapack.so\0", 0x4, 0x10060A800) = -1 Err#2 89795/0x1bfacf: access("/lib/libf77lapack.so\0", 0x4, 0x10060A800) = -1 Err#2 89795/0x1bfacf: access("/usr/lib/libf77lapack.so\0", 0x4, 0x10060A800) = -1 Err#2 89795/0x1bfacf: stat64("libf77lapack.so\0", 0x7FFF5FBFE630, 0x7FFF5FBFEC70) = -1 Err#2 89795/0x1bfacf: stat64("/Users/mellis/lib/libf77lapack.so\0", 0x7FFF5FBFEA10, 0x7FFF5FBFEC70) = -1 Err#2 89795/0x1bfacf: stat64("/usr/local/lib/libf77lapack.so\0", 0x7FFF5FBFEA10, 0x7FFF5FBFEC70) = -1 Err#2 89795/0x1bfacf: stat64("/usr/lib/libf77lapack.so\0", 0x7FFF5FBFEA20, 0x7FFF5FBFEC70) = -1 Err#2 89795/0x1bfacf: sigprocmask(0x1, 0x0, 0x7FFF5FBFEEC0) = 0x0 0 89795/0x1bfacf: sigaltstack(0x0, 0x7FFF5FBFEEB0, 0x0) = 0 0 89795/0x1bfacf: write(0x1, "ERROR: In procedure dynamic-link:\nERROR: In procedure dynamic-link: file: \"libf77lapack\", message: \"file not found\"\n\0", 0x74) = 116 0 If I try to specify the .dylib extension, dtruss shows that it fails because the standard extensions are being appended, e.g. open_nocancel("/usr/local/lib/libf77lapack.dylib.la\0", 0x0, 0x1B6) Is this something that can be fixed within Guile? Cheers, Mike ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: FFI on OS X? 2011-03-03 16:53 ` Michael Ellis @ 2011-03-03 19:49 ` Andy Wingo 0 siblings, 0 replies; 9+ messages in thread From: Andy Wingo @ 2011-03-03 19:49 UTC (permalink / raw) To: Michael Ellis; +Cc: bug-guile On Thu 03 Mar 2011 17:53, Michael Ellis <michael.f.ellis@gmail.com> writes: > On Thu, Mar 3, 2011 at 9:36 AM, Andreas Rottmann <a.rottmann@gmx.at> wrote: >> Hans Aberg <haberg-1@telia.com> writes: > >>>> Why does this fail? �Can you strace it? >>> >>> If you tell me how. :-) >>> >> Apparently, on OS X, "dtruss" does fulfill the role of "strace": >> <http://humberto.digi.com.br/blog/2008/02/25/strace-on-mac-os-x-leopard/>. > > For the record, here's some dtruss output created when I try to > dynamic-link a library that doesn't have a .so softlink, ie > (dynamic-link "libf77lapack") Aaahh yes I remember now. It should have been looking for .dylib but only wanted .so links, right? I think this is a libltdl bug. http://thread.gmane.org/gmane.lisp.guile.bugs/4483 There were a number of issues there, but I think the point about .dylib getting added to the default suffix list on OS X got lost. Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-03-03 19:49 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-03-02 20:07 FFI on OS X? Michael Ellis 2011-03-02 20:23 ` Hans Aberg 2011-03-02 21:22 ` Andy Wingo 2011-03-02 22:15 ` Hans Aberg 2011-03-03 9:25 ` Andy Wingo 2011-03-03 9:48 ` Hans Aberg 2011-03-03 14:36 ` Andreas Rottmann 2011-03-03 16:53 ` Michael Ellis 2011-03-03 19:49 ` Andy Wingo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).