7

我尝试使用 ECL 创建一个 .o 文件,目的是使用其编译为 C 的功能,但是在尝试将程序构建为文档列表时收到错误消息。

我在跑步:

(c:build-program "CompiledFile" "hello.lisp")

收到错误:

Debugger received error of type: SIMPLE-ERROR
Cannot find the external symbol BUILD-PROGRAM in #<"C" package>.
Error flushed.
>> "CompiledFile"
>> "hello.lisp"
>> ;;; Warning: Ignoring an unmatched right parenthesis.

hello.lisp的内容如下:

(defun say-hello ()
  (print "Hello, world"))

(say-hello)
(terpri)
(quit)

我正在关注此处找到的文档https://common-lisp.net/project/ecl/static/manual/ch34s03.html,它的函数定义为:

c:build-program {image-name &key lisp-files ld-flags prologue-code epilogue-code}

4

2 回答 2

5

根据https://ecls-list.narkive.com/xACoJUbf/c-build-program-and-eval编译器默认不加载,你需要使用

(require 'cmp)

第一的。

我不确定为什么手册中没有提到这一点。

于 2019-03-10T11:51:58.860 回答
1

根据ECL 手册,您需要初始化 C/C++ 编译器以生成 .o 文件:

(ext:install-c-compiler)
(compile-file "hello.lisp" :system-p t) ; Now this produces .o file

要从 .o 生成可执行文件:

(c:build-program "CompiledFile" :lisp-files '("hello.o"))
于 2021-04-30T19:14:33.460 回答