Until now, I have managed to build my Common Lisp project into a standalone executable with sbcl like this:
(sb-ext:save-lisp-and-die "myexecutable" :toplevel #'main :executable t)
Also, I have made it to call C functions, compiled into a shared library, from common lisp; something like this:
(cffi:define-foreign-library libtest
(:unix (:default "./libtest"))
(t (:default "./libtest")))
(cffi:use-foreign-library libtest)
or using an absolute path for the library. The produced executable needs the shared library, libtest.so. I have both myexecutable and libtest.so in the same directory. However, if I use an absolute I cannot distribute those two files. If I use "./libtest" it doesn't find the library when run from another directory.
What is the approach for this case? Thank you in advance!
Something like sb-ext:*runtime-pathname*
should give you the pathname of the executable.
* (describe '*runtime-pathname*)
SB-EXT:*RUNTIME-PATHNAME*
[symbol]
*RUNTIME-PATHNAME* names a special variable:
Value: #P"/usr/local/bin/sbcl"
Documentation:
The absolute pathname of the running SBCL runtime.
You can then compute a pathname for a file in the same directory:
* (merge-pathnames "libtest" *runtime-pathname*)
#P"/usr/local/bin/libtest"
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