我有以下包定义.如何递归编译所有组件,以及它们与C源的依赖关系?换句话说,我想保留构建本机可执行文件的所有 C文件.
目前,我使用(asdf:make-build :example但不会留下任何C文件.
我期待着看到
simple.c
simple.h
simple.data
cl-opengl.c
cl-opengl.h
...
Run Code Online (Sandbox Code Playgroud)
example.asd:
(defsystem :example
:depends-on (:cl-opengl :cl-glu :cl-glut)
:serial t
:components ((:file "simple")))
Run Code Online (Sandbox Code Playgroud)
CL-opengl.asd:
(defsystem cl-opengl
:description "Common Lisp bindings to OpenGL."
:depends-on (cffi alexandria)
:components
((:module "gl"
:components
((:file "bindings-package")
(:file "constants" :depends-on ("bindings-package"))
(:file "library" :depends-on ("bindings-package"))
(:file "bindings" :depends-on ("bindings-package" "constants" "library"))
...
Run Code Online (Sandbox Code Playgroud) 做一个SWIG教程,并使用example.c,example.i,因为他们在那里提供.我生成了lisp文件swig -cffi example.i.
但是,当我test.lisp与SBCL一起运行时,我会收到关于未定义外来函数的投诉,以及编译example.lisp自身时的投诉.我很确定我仍然需要将我的example.c编译成一个库然后以某种方式告诉SBCL加载它!但该文档是在这个非常稀少,除了这个.
有人可以告诉我如何做到这一点,还是有一种比SWIG更好的方法从C/C++源自动生成CFFI绑定?
sbcl输出:
...
;
; caught STYLE-WARNING:
; Undefined alien: "fact"
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
;
; caught STYLE-WARNING:
; Undefined alien: "my_mod"
...
Run Code Online (Sandbox Code Playgroud)
test.lisp
;call C functions defined in example.c
(require :cffi)
;;;(require :example "example.lisp")
(load "example.lisp")
(fact 2)
(quit)
Run Code Online (Sandbox Code Playgroud)