Arc Forumnew | comments | leaders | submitlogin
2 points by eds 6099 days ago | link | parent

Thanks for your suggestion.

I do have one question about loading libc. Since the system doesn't automatically find libc.so for you, you need to name the path explicitly. What worked for me was

  (w/ffi "/lib/libc.so.6"
    (cdef fork "fork" cint ()))
but I don't really know if this is the right way to do it. Is there a better way?


2 points by elibarzilay 6099 days ago | link

The underlying foreign implementation is looking for the library. The problem is that /usr/lib/libc.so is not the library and dlopen() does not know how to handle this.

A better alternative with mzscheme's foreign interface is to use `#f' for the library -- that treats the mzscheme binary as the library to open (which includes the usual libc stuff.)

-----

1 point by sacado 6099 days ago | link

Interesting. Should be added to ffi.arc...

-----

2 points by eds 6099 days ago | link

Yeah, because currently if you attempt

  (w/ffi #f
    (cdef cfork "fork" cint ()))
arc will convert #f to nil, which mzcheme thinks is an unbound variable. There are work-arounds, like

  (w/ffi (read "#f")
    (cdef cfork "fork" cint ()))
but this is rather ugly.

-----