Search code examples
ccompiler-errorslispcommon-lispecl

What is the correct way to compile a file using Embeddable Common Lisp?


I attempting to use ECL to create a .o file with the intention of using its feature of compiling to C however I am receiving an error when trying to build a program as the documentation lists.

I am running:

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

An receiving the error:

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.

The contents of hello.lisp are as follows:

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

(say-hello)
(terpri)
(quit)

I am following the documentation found here https://common-lisp.net/project/ecl/static/manual/ch34s03.html and it has the function definition as:

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


Solution

  • According to https://ecls-list.narkive.com/xACoJUbf/c-build-program-and-eval the compiler isn't loaded by default, you need to use

    (require 'cmp)
    

    first.

    I'm not sure why this isn't mentioned in the manual.