I am using SBCL, although I have seen other implementations have similar functionality. I can dump an executable that does not require the Lisp implementation to be installed, but does rely on the standard C library. How can I make the dumped image be statically linked (i.e. have no dependencies whatsoever)?
When I am done using an image, I can call
(save-lisp-and-die "image-name" :executable t)
this will leave a file called image-name
in my directory that I can then call with ./image-name
. I will be dropped into a repl and everything I had done before saving-lisp-an-dying will still be there. My problem is that when I move this file to another machine, I cannot run it. Either I get the 'file not found' error, or I am told that the wrong version of GLIBC is installed. Running file
on the image reveals it was dynamically linked. Is there a way to dump a statically linked image that I can just copy to any machine with a Linux kernel?
Generate a dynamically linked executable with
(save-lisp-and-die "image-name" :executable t)
Then use one of the differents ways to generate a statically linked executable from a dynamically linked executable.
I've tried with packelf.sh, it works great !