[cffi-devel] %load-foreign-library on SBCL
Elliott Slaughter
elliottslaughter at gmail.com
Tue Dec 22 00:52:24 UTC 2009
On Mon, Dec 21, 2009 at 1:26 PM, Luís Oliveira <luismbo at gmail.com> wrote:
> On Mon, Dec 21, 2009 at 8:55 PM, Elliott Slaughter
> <elliottslaughter at gmail.com> wrote:
> > I'm believe I'm seeing this issue again, but none of my previous
> workarounds
> > seem to be working. I am using SBCL 1.0.29 on Windows XP, and when I save
> > and run an executable, I keep getting undefined alien errors. I have
> tried
> > both the :dont-save t hack that I initially suggested, and have tried
> > calling (close-foreign-library ...) on all of the open libraries before
> > saving the executable, and nothing helps.
>
> Can you come up with a minimal test case? Something using e.g.
> libtest.dll would be nice.
>
Sure.
For this test, I used SDL.dll from
http://www.libsdl.org/release/SDL-1.2.14-win32.zip .
$ cat test.lisp
(asdf:oos 'asdf:load-op :cffi)
(cffi:define-foreign-library sdl
(:windows "SDL.dll"))
(cffi:use-foreign-library sdl)
(cffi:defcfun ("SDL_Linked_Version" SDL-Linked-Version) :pointer)
(defun main () (format t "does it work?~%") (quit))
(cffi:close-foreign-library 'sdl)
(save-lisp-and-die #+windows "main.exe" #-windows "main"
:toplevel #'main :executable t)
$ sbcl --load test.lisp
This is SBCL 1.0.29, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
This is experimental prerelease support for the Windows platform: use
at your own risk. "Your Kitten of Death awaits!"
; loading system definition from C:\Bin\asdf\cffi\cffi.asd into
; #<PACKAGE "ASDF0">
; registering #<SYSTEM CFFI {23FFE3B9}> as CFFI
; loading system definition from C:\Bin\asdf\babel\babel.asd into
; #<PACKAGE "ASDF0">
; registering #<SYSTEM BABEL {242FC621}> as BABEL
; loading system definition from C:\Bin\asdf\alexandria\alexandria.asd into
; #<PACKAGE "ASDF0">
; registering #<SYSTEM :ALEXANDRIA {2449AB61}> as ALEXANDRIA
; loading system definition from
; C:\Bin\asdf\trivial-features\trivial-features.asd into #<PACKAGE "ASDF0">
; registering #<SYSTEM TRIVIAL-FEATURES {246A9BF9}> as TRIVIAL-FEATURES
WARNING:
Saving cores with alien definitions referring to non-static foreign
symbols
is unsupported on this platform: references to such foreign symbols from
the
restarted core will not work. You may be able to work around this
limitation
by reloading all foreign definitions and code using them in the restarted
core, but no guarantees.
Dynamic
foreign symbols in this core: SDL_Linked_Version
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into main.exe:
writing 2888 bytes from the read-only space at 0x22000000
writing 1736 bytes from the static space at 0x22100000
writing 27688960 bytes from the dynamic space at 0x22300000
done]
$ ./main.exe
This is experimental prerelease support for the Windows platform: use
at your own risk. "Your Kitten of Death awaits!"
debugger invoked on a UNDEFINED-ALIEN-ERROR:
Undefined alien: "SDL_Linked_Version"
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
(no restarts: If you didn't do this on purpose, please report it as a bug.)
(SB-SYS:ENSURE-DYNAMIC-FOREIGN-SYMBOL-ADDRESS
"SDL_Linked_Version"
#<unused argument>)
0]
WARNING: Starting a select without a timeout while interrupts are disabled.
ba
0: (SB-SYS:ENSURE-DYNAMIC-FOREIGN-SYMBOL-ADDRESS
"SDL_Linked_Version"
#<unused argument>)
1: ((FLET SB-THREAD::WITH-RECURSIVE-SYSTEM-SPINLOCK-THUNK))
2: ((FLET
#:WITHOUT-INTERRUPTS-BODY-[CALL-WITH-RECURSIVE-SYSTEM-SPINLOCK]196))
3: (SB-THREAD::CALL-WITH-RECURSIVE-SYSTEM-SPINLOCK
#<CLOSURE (FLET SB-THREAD::WITH-RECURSIVE-SYSTEM-SPINLOCK-THUNK)
{22FCDD}>
#<unavailable argument>)
4: (SB-SYS:UPDATE-LINKAGE-TABLE)
5: (SB-IMPL::FOREIGN-REINIT)
6: (SB-IMPL::REINIT)
7: ((LABELS SB-IMPL::RESTART-LISP))
8: ("foreign function: #x4120C4")
9: ("foreign function: #x40AF88")
0]
WARNING: Starting a select without a timeout while interrupts are disabled.
(quit)
--
Elliott Slaughter
"Don't worry about what anybody else is going to do. The best way to predict
the future is to invent it." - Alan Kay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20091221/34f22cae/attachment.html>
More information about the cffi-devel
mailing list