以上篇博客Linux下動態連接庫文件的編譯與使用中的libmodulec.so庫爲例,編寫調用代碼: spa
(asdf:oos 'asdf:load-op :cffi) (defpackage :cffi-user (:use :common-lisp :cffi)) (in-package :cffi-user) (defvar *lib-handler* nil) (defun load-foreign-lib () (setq *lib-handler* (load-foreign-library "libmodulec.so" :search-path "~/projects/swig_prj/"))) (defun exec-foreign-interface () (foreign-funcall add-nums :int 4 :int 8 :int)) (defun unload-foreign-lib () (close-foreign-library *lib-handler*))
執行過程及結果以下: .net