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}
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.
According to ECL manual, you need to initialize C/C++ compiler to generate the .o files:
(ext:install-c-compiler)
(compile-file "hello.lisp" :system-p t) ; Now this produces .o file
To generate an executable from .o:
(c:build-program "CompiledFile" :lisp-files '("hello.o"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With