chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] lazy-ffi: what am I missing?


From: Jeronimo Pellegrini
Subject: [Chicken-users] lazy-ffi: what am I missing?
Date: Tue, 30 Mar 2010 23:06:29 -0300
User-agent: Mutt/1.5.20 (2009-06-14)

Hi,

I am trying to get this example from the lazy-ffi documentation
working, but I don't know what I'm doing wrong...

This is the code:

thing.scm
/---
(use lazy-ffi)
(use numbers)

#~"libc.so.6" 
(#~printf "%d -> %g, ok: %s\n" 123 45.67 "hello")

#~"libm.so.6"

(print (#~sin 33.4 return: double:)   )
(print (#~tolower #\A return: char:) )

(let* ([box (f64vector 0)]
       [r (#~modf 123.456 box return: double:)] )
  (print (list r box) )  )
\---

It compiles but doesn't work when doubles are used:

$ csc -X lazy-ffi.scm thing.scm

(Do I really need to include the lazy-ffi source when compiling?)

$ ./thing

123 -> 45.67, ok: hello

Error: unbound variable: ##sys#cons-flonum

    Call history:

    ##sys#require       
    ##sys#require       
    lazy-ffi#lazy-ffi:module        
    lazy-ffi#lazy-ffi:function      
    g5354       
    lazy-ffi#lazy-ffi:module        
    thing.scm:8: lazy-ffi#lazy-ffi:function     
    g5556           <--

I have tried downloading the libffi-2.tgz mentioned at 
http://chicken.wiki.br/eggref/4/lazy-ffi but got a 404.

>From the interpreter the same thing happens:

#;1> (use lazy-ffi)
; loading /usr/local/lib/chicken/5/lazy-ffi.so ...
; loading /usr/local/lib/chicken/5/lazy-ffi.import.so ...
; loading /usr/local/lib/chicken/5/scheme.import.so ...
; loading /usr/local/lib/chicken/5/chicken.import.so ...
; loading /usr/local/lib/chicken/5/foreign.import.so ...
; loading /usr/local/lib/chicken/5/srfi-1.import.so ...
; loading /usr/local/lib/chicken/5/srfi-69.import.so ...
; loading /usr/local/lib/chicken/5/easyffi.import.so ...
; loading /usr/local/lib/chicken/5/lazy-ffi-support.so ...
#;2> (use numbers)
; loading /usr/local/lib/chicken/5/numbers.import.so ...
; loading /usr/local/lib/chicken/5/regex.import.so ...
; loading /usr/local/lib/chicken/5/numbers.so ...
#;3> #~"libc.so.6"
(libc.so.6)
#;4> (#~printf "%d -> %g, ok: %s\n" 123 45.67 "hello")
123 -> 45.67, ok: hello
#;5> #~"libm.so.6"
(libm.so.6 libc.so.6)
#;6> (print (#~sin 33.4 return: double:)   )

Error: unbound variable: ##sys#cons-flonum

    Call history:

    <syntax>        (lazy-ffi:function (quote sin) (quote 
lazy-ffi:1270000602.07337570))
    <syntax>        (quote sin)
    <syntax>        (##core#quote sin)
    <syntax>        (quote lazy-ffi:1270000602.07337570)
    <syntax>        (##core#quote lazy-ffi:1270000602.07337570)
    <eval>      (print ((lazy-ffi:function (quote sin) (quote 
lazy-ffi:1270000602.07337570)) 33.4 return: double:))
    <eval>      ((lazy-ffi:function (quote sin) (quote 
lazy-ffi:1270000602.07337570)) 33.4 return: double:)
    <eval>      (lazy-ffi:function (quote sin) (quote 
lazy-ffi:1270000602.07337570))    <--


Is there something else I should load before using this extension?

I'm using Chicken master/HEAD and:

lazy-ffi 1.8.2;
numbers 1.809;
silex 1.2;
easyffi 1.99.1.

Thank you!
J.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]