Vinn
Vinn

Reputation: 1181

Common Lisp: Exported Function Undefined

I have created an executable a few times with the asdf system. I know there are other ways to do this but I want to figure out why this is not working this time.

I have a rock-paper-scissor game.

The lisp file:

(defun main ()
  (let* ((x (y-or-n-p (format t "Is there two players? [Y/N]"))))
    (if (equal x t)
    (rps-game2)
    (rps-game))))

... other stuff

The package.lisp:


(defpackage #:rps
      (:use #:cl)
      (:export main))

The rps.asd


(asdf:defsystem #:rps
       :components ((:file "package")
                    (:file "rps"))
        :build-operation "program-op"
        :build-pathname "launch"
        :entry-point "rps:main")


The makefile:


build:
    sbcl \
     --eval '(load "rps.asd")' \
    --eval '(ql:quickload "rps")' \
     --eval '(asdf:make :rps)' \
     --eval '(quit)'



The error message:

The function rps:main is an undefined

I followed the exact same process as a previous package I created. For some reason, main is unrecognised this time. Why?

Upvotes: 0

Views: 129

Answers (1)

Vinn
Vinn

Reputation: 1181

I found the following issues:

  1. In my rps.asd I added serial t. I believe this tells lisp to compile the files in order. Therefore the package gets compiled first, then the rps file.
  2. I added (in-package #:rps) to the rps.lisp file. (thanks @Numbra)

Upvotes: 1

Related Questions