I was mistaken, I did not successfully call Lisp function
from C side.
I wonder if you can do this successfully:
1. put SBCL source code to $SRC
2. build SBCL and libsbcl.so:
cd $SRC
./make.sh
./make-shared-library.sh
3. dump a Lisp core:
==== test.lisp ====
(sb-alien:define-alien-callable fun1 sb-alien:int () 2)
(sb-ext:save-lisp-and-die "test.core" :callable-exports '(fun1))
==== end test.lisp ====
$SRC/run-sbcl.sh --load test.lisp
4. build a C executable:
==== test.c ====
#include <stdio.h>
extern int initialize_lisp(int argc, char *argv[], char *envp[]);
int main(int argc, char *argv[], char *envp[]){
int sargc=4;
char * sargv[] = {argv[0], "--core", "test.core", "--no-sysinit", };
printf("start init\n");
initialize_lisp(sargc, sargv, envp);
printf("finish init\n");
return 0;
}
==== end test.c ====
cc test.c $SRC/runtime/libsbcl.so -o app
5. execute the "./app" and you get error in
"foreign function: call_into_lisp_".
Looks like the error is because it can't initialize the foreign
function correctly.
- Qian