Hello, I am having trouble running the cffi examples on clisp/allegrocl on windows xp. (cffi-luis-050925-2059)
First of all do I need some dll or library to run the examples? The tar ball doesn't contain anything.
When I load the file through slime I get the error FFI::FOREIGN-LIBRARY-FUNCTION: no dynamic object named "sqrtf" in library :DEFAULT
but loading on the command line works fine. But if from the command line I execute,
[3]> (cffi-examples:sqrtf 5)
*** - FFI::FOREIGN-LIBRARY-FUNCTION: no dynamic object named "sqrtf" in library :DEFAULT The following restarts are available: USE-VALUE :R1 You may input a value to be used instead. ABORT :R2 ABORT Break 1 [4]> :R2
[6]> (cffi-examples:gettimeofday)
*** - FFI::FOREIGN-LIBRARY-FUNCTION: no dynamic object named "gettimeofday" in library :DEFAULT The following restarts are available: USE-VALUE :R1 You may input a value to be used instead. ABORT :R2 ABORT Break 1 [7]>
Only gethostname function seems to work.
Thanks.
On 26/set/2005, at 05:51, Surendra Singhi wrote:
When I load the file through slime I get the error FFI::FOREIGN-LIBRARY-FUNCTION: no dynamic object named "sqrtf" in library :DEFAULT
but loading on the command line works fine.
That's probably because SLIME tried to compile the file. And at load-time, for compiled code, CLISP will try to lookup the foreign function (and it understandably fails, see below).
(By the way Kenny, if we remove that LOAD-TIME-VALUE in cffi-clisp.lisp's %FOREIGN-FUNCALL, CLISP will probably work dynamically like you like. Need to see how slower that would be before making such a change though. Although I'm still not convinced this much necessary.)
But if from the command line I execute,
I suppose here you just used the interpreter, this way CLISP will only lookup the foreign functions when trying to execute.
[3]> (cffi-examples:sqrtf 5)
*** - FFI::FOREIGN-LIBRARY-FUNCTION: no dynamic object named "sqrtf" in library :DEFAULT
*** - FFI::FOREIGN-LIBRARY-FUNCTION: no dynamic object named "gettimeofday" in library :DEFAULT
But the real problem is that sqrtf and gettimeofday are UNIX only, they don't exist in Windows. Well at least not in the C library your CLISP is using.
Thanks for your interest in CFFI!
Hello Luis,
Thanks for your explanations. CFFI is really cool. I tried using CFFI for wxCL and it works on clisp, and lispworks. But, I am getting segmentation faults on Allegro which is making allegro crash.
I have few suggestions/requests for cffi, I am only familiar with clisp ffi, so pardon me if I am only seeing world from clisp angle. If these, are already present in cffi, then please point me to them.
[1]I didn't find any function for closing foreign libraries. This is needed because, some libraries (wxWidgets, for instance) has static initializers problem, once the program finishes, if the interpreter tries to run the program again the library will crash as things don't get initialized properly second time.
[2]Also, I have not investigated the reason why allegro crashes, but one reason could be different argument passing conventions. But I didn't find any way of specifying the argument-passing conventions.
Thanks for your help.
On 27/set/2005, at 01:43, Surendra Singhi wrote:
[1]I didn't find any function for closing foreign libraries. This is needed because, some libraries (wxWidgets, for instance) has static initializers problem, once the program finishes, if the interpreter tries to run the program again the library will crash as things don't get initialized properly second time.
Noted. The support for dealing with foreign libraries is pretty weak right now. I'll look into this soon, as it seems pretty straightforward to add.
[2]Also, I have not investigated the reason why allegro crashes, but one reason could be different argument passing conventions. But I didn't find any way of specifying the argument-passing conventions.
Unlikely, because Allegro has IMHO the *best* behaviour regarding calling conventions. Things will work unchanged with either stdcall or cdecl. That is what I would like CFFI to do, but that doesn't seem possible in the near future, unfortunately. So we will need to add a way to specify calling conventions.
It'd be nice if you could send a reproducible test case for that Allegro crash (the smaller the better :-)).
Thanks,
Hello Luis,
Luis Oliveira luismbo@gmail.com writes:
It'd be nice if you could send a reproducible test case for that Allegro crash (the smaller the better :-)).
Attached is the test-case, it crashes Allegro 7.0 trial edition, runs fine on both lispworks and clisp. It is pretty short and I have put comments so that it is easy to understand.
The dll can be downloaded from http://cvs.sourceforge.net/viewcvs.py/wxcl/miscellaneous/
It is named wxc-msw2.6.2.dll
Note, to run it multiple times on clisp/lispworks you need to close the library explicitly.
Thanks for the help.
On 2005-sep-27, at 01:43, Surendra Singhi wrote:
[1]I didn't find any function for closing foreign libraries. This is needed because, some libraries (wxWidgets, for instance) has static initializers problem, once the program finishes, if the interpreter tries to run the program again the library will crash as things don't get initialized properly second time.
Hello Surendra,
I just pushed a patch to cffi-luis that implements close-foreign- library for CMUCL, SBCL, Allegro, CLISP, Lispworks and OpenMCL. It's still unexported so you'll have to call it using (cffi::close-foreign- library <name>).
Do let me know if it works for you.
Luís Oliveira luismbo@gmail.com writes:
On 2005-sep-27, at 01:43, Surendra Singhi wrote:
[1]I didn't find any function for closing foreign libraries. This is needed because, some libraries (wxWidgets, for instance) has static initializers problem, once the program finishes, if the interpreter tries to run the program again the library will crash as things don't get initialized properly second time.
Hello Surendra,
I just pushed a patch to cffi-luis that implements close-foreign- library for CMUCL, SBCL, Allegro, CLISP, Lispworks and OpenMCL. It's still unexported so you'll have to call it using (cffi::close-foreign- library <name>).
Thanks.
Do let me know if it works for you.
Sure, I will test it and let you know in couple of days.