【发布时间】:2018-12-06 19:14:15
【问题描述】:
我正在尝试在 Chicken Scheme 中使用一些内联 C 在 OS X 上编写一个简单的程序,其中 Chicken 已经安装了自制软件。
;; add1.ss
(import foreign)
(define add-1
(foreign-lambda* long ((unsigned-long x))
"
long n = 1
C_return(n + x);))
(print (add-1 (read)))
我感兴趣的foreign库肯定存在。
find /usr/local | grep chicken | grep foreign | grep lib
/usr/local//Cellar/chicken/5.0.0/lib/chicken/9/chicken.foreign.import.so
但是,通过 csc add1.ss 编译我的程序,在 CSC_OPTIONS 环境变量中没有标志会产生:
$ csc add1.ss
Syntax error (import): cannot import from undefined module
foreign
Expansion history:
<syntax> (##core#begin (import foreign))
<syntax> (import foreign) <--
Error:shell command terminated with non-zero exit status 17920:
'/usr/local/Cellar/chicken/bin/5.0.0/bin/chicken' 'add1.ss' -output-file 'add1.c'
所以,这个错误信息很有意义,运行
$ chicken add1.ss -output-file add1.c
产生同样的失败。在小鸡手册页中,唯一看似与路径管理相关的命令行选项是-include-path。我尝试了以下咒语,它们都产生了相同的错误
$ chicken add1.ss -output-file add1.c -include-path /usr/local/Cellar/chicken/5.0.0/lib/chicken/9/chicken.foreign.import.so
$ chicken add1.ss -output-file add1.c -include-path /usr/local/Cellar/chicken/5.0.0/lib/chicken/9
$ chicken add1.ss -output-file add1.c -include-path /usr/local/Cellar/chicken/5.0.0/lib/chicken
$ chicken add1.ss -output-file add1.c -include-path /usr/local/Cellar/chicken/5.0.0/lib
$ chicken add1.ss -output-file add1.c -include-path /usr/local/Cellar/chicken/5.0.0
我还尝试将chicken.foreign.import.so 作为附加的“要编译的文件”传递,但无济于事:
$ chicken add1.ss -output-file add1.c /usr/local/Cellar/chicken/5.0.0/lib/chicken/9/chicken.foreign.import.so
产生了同样的错误信息。
指示chicken或编译驱动csc在/usr/local/Cellar/chicken/...下的目录中查找Chicken的内部库的正确方法是什么?
【问题讨论】:
标签: scheme chicken-scheme