ecl 如何在可执行文件中包含 asdf 依赖项? (取2)

发布于 2024-08-19 05:02:08 字数 6417 浏览 17 评论 0原文

中提出并回答

此问题由 ayrnieu 在ECL 如何包含 ASDF 可执行文件中的依赖项?

但他链接到的示例代码实际上并不涉及任何依赖项。我尝试复制他提到的 Stumpwm 代码中的模型,但我无法让它工作。他是我的档案。

---- ecl-test.asd ----

(defsystem "ecl-test"
  :description "test of asdf:make-build"
  :depends-on (:mydefs)
  :components ((:file "package")
  (:file "ecl-test" :depends-on ("package"))
  (:file "main" :depends-on ("package" "ecl-test"))
        )
)

---- ecl-test.lisp ----

    (in-package :ecl-test)

    (defun test ()
      (format t "testing...~%")

;; Note that with the next line commented out,
;; the program never uses the package "mydefs".
;;    (format t (write-to-string (mydefs:number-sequence :from 2 :to 7)))

      (format t "...done~%"))

---- package.lisp ----

(defpackage :ecl-test
  (:use :cl 
 :mydefs
 )
  (:export :test))

---- main.lisp ----

(ecl-test:test)
(ext:quit)

编译成功(在 slime 中):

CL-USER> (asdf:make-build 'ecl-test :type :program :monolithic t :epilogue-code '(ext:quit 0))

; loading system definition from /home/dabrowsa/lisp/ecl-test/ecl-test.asd into
; #<ASDF0 package>
;;; Loading "/home/dabrowsa/lisp/ecl-test/ecl-test.asd"
;;; Compiling /home/dabrowsa/lisp/ecl-test/package.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; End of Pass 1.
;;; Note: Creating tag: "_eclitxZgyvjVscp1_KzxnJ9z" for #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/package.c" -o "/home/dabrowsa/lisp/ecl-test/package.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/package.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Found tag: "_eclitxZgyvjVscp1_KzxnJ9z" for /home/dabrowsa/lisp/ecl-test/package.o
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITMs8gOO.c" -o "/tmp/ECLINITMs8gOO.o"
;;; Note: Invoking external command:
;;;   gcc -o "/home/dabrowsa/lisp/ecl-test/package.fas" -L"/usr/lib/" "/tmp/ECLINITMs8gOO.o" "/home/dabrowsa/lisp/ecl-test/package.o"   -shared    -lecl  -lgmp -lgc -ldl  -lm 
;;; Loading "/home/dabrowsa/lisp/ecl-test/package.fas"
;;; Compiling /home/dabrowsa/lisp/ecl-test/ecl-test.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; Compiling (DEFUN TEST ...).
;;; End of Pass 1.
;;; Note: Creating tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Emitting code for TEST.
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/ecl-test.c" -o "/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/ecl-test.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Note: Found tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for /home/dabrowsa/lisp/ecl-test/ecl-test.o
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITg28qfo.c" -o "/tmp/ECLINITg28qfo.o"
;;; Note: Invoking external command:
;;;   gcc -o "/home/dabrowsa/lisp/ecl-test/ecl-test.fas" -L"/usr/lib/" "/tmp/ECLINITg28qfo.o" "/home/dabrowsa/lisp/ecl-test/ecl-test.o"   -shared    -lecl  -lgmp -lgc -ldl  -lm 
;;; Loading "/home/dabrowsa/lisp/ecl-test/ecl-test.fas"
;;; Compiling /home/dabrowsa/lisp/ecl-test/main.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; End of Pass 1.
;;; Note: Creating tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/main.c" -o "/home/dabrowsa/lisp/ecl-test/main.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/main.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Found tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITeop9MY.c" -o "/tmp/ECLINITeop9MY.o"
;;; Note: Invoking external command:
;;;   gcc -o "/home/dabrowsa/lisp/ecl-test/main.fas" -L"/usr/lib/" "/tmp/ECLINITeop9MY.o" "/home/dabrowsa/lisp/ecl-test/main.o"   -shared    -lecl  -lgmp -lgc -ldl  -lm 
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Found tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Note: Found tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for /home/dabrowsa/lisp/ecl-test/ecl-test.o
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Found tag: "_eclitxZgyvjVscp1_KzxnJ9z" for /home/dabrowsa/lisp/ecl-test/package.o
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITsLgWth.c" -o "/tmp/ECLINITsLgWth.o"
;;; Note: Invoking external command:
;;;   ar cr /home/dabrowsa/lisp/ecl-test/libecl-test.a /tmp/ECLINITsLgWth.o /home/dabrowsa/lisp/ecl-test/package.o /home/dabrowsa/lisp/ecl-test/ecl-test.o /home/dabrowsa/lisp/ecl-test/main.o 
;;; Note: Invoking external command:
;;;   ranlib /home/dabrowsa/lisp/ecl-test/libecl-test.a
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITTF1dqA.c" -o "/tmp/ECLINITTF1dqA.o"
;;; Note: Invoking external command:
;;;   gcc -o "/home/dabrowsa/lisp/ecl-test/ecl-test-mono" -L"/usr/lib/" "/tmp/ECLINITTF1dqA.o" "/home/dabrowsa/lisp/ecl-test/libecl-test.a"     -lecl  -lgmp -lgc -ldl  -lm #<ASDF::PROGRAM-OP NIL 38147728>

但是执行 ecl-test-mono 会产生错误。

~/lisp/ecl-test$ ./ecl-test-mono

The function ASDF::SYSTEM-REGISTERED-P is undefined.
No restarts available.

Broken at NIL.
ECL-TEST>>

SYSTEM-REGISTERED-P 似乎是 ASDF 中的一个未导出函数,我不知道为什么会出现在这里,但是,我是新手,所以我知道什么。

This question was asked and answered by ayrnieu at

How can ECL include ASDF dependencies in an executable?

But the example code he linked to does not actually involve any dependencies. I've tried copying the model in the stumpwm code he refers to but I can't get it to work. He are my files.

---- ecl-test.asd ----

(defsystem "ecl-test"
  :description "test of asdf:make-build"
  :depends-on (:mydefs)
  :components ((:file "package")
  (:file "ecl-test" :depends-on ("package"))
  (:file "main" :depends-on ("package" "ecl-test"))
        )
)

---- ecl-test.lisp ----

    (in-package :ecl-test)

    (defun test ()
      (format t "testing...~%")

;; Note that with the next line commented out,
;; the program never uses the package "mydefs".
;;    (format t (write-to-string (mydefs:number-sequence :from 2 :to 7)))

      (format t "...done~%"))

---- package.lisp ----

(defpackage :ecl-test
  (:use :cl 
 :mydefs
 )
  (:export :test))

---- main.lisp ----

(ecl-test:test)
(ext:quit)

This compiles successfully (in slime):

CL-USER> (asdf:make-build 'ecl-test :type :program :monolithic t :epilogue-code '(ext:quit 0))

; loading system definition from /home/dabrowsa/lisp/ecl-test/ecl-test.asd into
; #<ASDF0 package>
;;; Loading "/home/dabrowsa/lisp/ecl-test/ecl-test.asd"
;;; Compiling /home/dabrowsa/lisp/ecl-test/package.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; End of Pass 1.
;;; Note: Creating tag: "_eclitxZgyvjVscp1_KzxnJ9z" for #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/package.c" -o "/home/dabrowsa/lisp/ecl-test/package.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/package.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Found tag: "_eclitxZgyvjVscp1_KzxnJ9z" for /home/dabrowsa/lisp/ecl-test/package.o
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITMs8gOO.c" -o "/tmp/ECLINITMs8gOO.o"
;;; Note: Invoking external command:
;;;   gcc -o "/home/dabrowsa/lisp/ecl-test/package.fas" -L"/usr/lib/" "/tmp/ECLINITMs8gOO.o" "/home/dabrowsa/lisp/ecl-test/package.o"   -shared    -lecl  -lgmp -lgc -ldl  -lm 
;;; Loading "/home/dabrowsa/lisp/ecl-test/package.fas"
;;; Compiling /home/dabrowsa/lisp/ecl-test/ecl-test.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; Compiling (DEFUN TEST ...).
;;; End of Pass 1.
;;; Note: Creating tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Emitting code for TEST.
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/ecl-test.c" -o "/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/ecl-test.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Note: Found tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for /home/dabrowsa/lisp/ecl-test/ecl-test.o
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITg28qfo.c" -o "/tmp/ECLINITg28qfo.o"
;;; Note: Invoking external command:
;;;   gcc -o "/home/dabrowsa/lisp/ecl-test/ecl-test.fas" -L"/usr/lib/" "/tmp/ECLINITg28qfo.o" "/home/dabrowsa/lisp/ecl-test/ecl-test.o"   -shared    -lecl  -lgmp -lgc -ldl  -lm 
;;; Loading "/home/dabrowsa/lisp/ecl-test/ecl-test.fas"
;;; Compiling /home/dabrowsa/lisp/ecl-test/main.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; End of Pass 1.
;;; Note: Creating tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/main.c" -o "/home/dabrowsa/lisp/ecl-test/main.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/main.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Found tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITeop9MY.c" -o "/tmp/ECLINITeop9MY.o"
;;; Note: Invoking external command:
;;;   gcc -o "/home/dabrowsa/lisp/ecl-test/main.fas" -L"/usr/lib/" "/tmp/ECLINITeop9MY.o" "/home/dabrowsa/lisp/ecl-test/main.o"   -shared    -lecl  -lgmp -lgc -ldl  -lm 
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Found tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Note: Found tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for /home/dabrowsa/lisp/ecl-test/ecl-test.o
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Found tag: "_eclitxZgyvjVscp1_KzxnJ9z" for /home/dabrowsa/lisp/ecl-test/package.o
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITsLgWth.c" -o "/tmp/ECLINITsLgWth.o"
;;; Note: Invoking external command:
;;;   ar cr /home/dabrowsa/lisp/ecl-test/libecl-test.a /tmp/ECLINITsLgWth.o /home/dabrowsa/lisp/ecl-test/package.o /home/dabrowsa/lisp/ecl-test/ecl-test.o /home/dabrowsa/lisp/ecl-test/main.o 
;;; Note: Invoking external command:
;;;   ranlib /home/dabrowsa/lisp/ecl-test/libecl-test.a
;;; Note: Invoking external command:
;;;   gcc "-I/usr/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECLINITTF1dqA.c" -o "/tmp/ECLINITTF1dqA.o"
;;; Note: Invoking external command:
;;;   gcc -o "/home/dabrowsa/lisp/ecl-test/ecl-test-mono" -L"/usr/lib/" "/tmp/ECLINITTF1dqA.o" "/home/dabrowsa/lisp/ecl-test/libecl-test.a"     -lecl  -lgmp -lgc -ldl  -lm #<ASDF::PROGRAM-OP NIL 38147728>

But executing ecl-test-mono produces an error.

~/lisp/ecl-test$ ./ecl-test-mono

The function ASDF::SYSTEM-REGISTERED-P is undefined.
No restarts available.

Broken at NIL.
ECL-TEST>>

SYSTEM-REGISTERED-P seems to be an unexported function in ASDF, I have no idea why that's popping up here, but then, I'm a newbie so what do I know.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你最好在 ecls-list 上问这个问题。

或者在对 MAKE-BUILD 的调用中尝试以下操作:

:prologue-code '(require :asdf)

You're better off asking this on ecls-list.

Or try this in your call to MAKE-BUILD:

:prologue-code '(require :asdf)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文