(defun load-shared-object (file)
"Load a shared library/dynamic shared object file/general
-dlopenable alien container.
+dlopenable alien container, such as a .so on an ELF platform.
-To use LOAD-SHARED-OBJECT, at the Unix command line do this:
-
- echo 'int summish(int x, int y) { return 1 + x + y; }' > /tmp/ffi-test.c
- make /tmp/ffi-test.o # i.e. cc -c -o /tmp/ffi-test.o /tmp/ffi-test.c
- ld -shared -o /tmp/ffi-test.so /tmp/ffi-test.o
-
-Then in SBCL do this:
-
- (load-shared-object \"/tmp/ffi-test.so\")
- (define-alien-routine summish int (x int) (y int))
-
-Now running (summish 10 20) should return 31."
+References to foreign symbols in loaded shared objects do not survive
+intact through SB-EXT:SAVE-LISP-AND die on all platforms. See
+SB-EXT:SAVE-LISP-AND-DIE for details."
(let* ((real-file (or (unix-namestring file) file))
(sap (dlopen-or-lose real-file))
(obj (make-shared-object :file real-file :sap sap)))
;;; Open libraries in *SHARED-OBJECTS* and the runtime. Called during
;;; initialization.
(defun reopen-shared-objects ()
- ;; Ensure that the runtime is present in the list
+ ;; Ensure that the runtime is open
(setf *runtime-dlhandle* (dlopen-or-lose nil)
*shared-objects* (mapcar #'try-reopen-shared-object *shared-objects*)))