Building SBCL - Steel Bank Common Lisp on Windows
Posted on August 20, 2019 by Paul
In this article, I will show you how to build the latest stable version of SBCL - Steel Bank Common Lisp on Windows. The officially provided binary of SBCL for Windows is typically older than the latest stable version, so I wrote this tutorial in the hope that it will be useful for people that want to use the latest version of SBCL. The article will also be useful for people that want to customize the installation of SBCL, for example you could build SBCL with more or less memory than the default 1GB that is allocated for the 64 bits version.
In order to build SBCL we’ll need another Common Lisp compiler, one will typically use an older version of SBCL and a C compiler with the GNU binutils. For this article I will use the latest provided SBCL Windows 64 bits binary which is at version 1.4.14 at the time of this writing. For the C compiler and GNU binutils I will use the MSYS2 distribution. The advantage of this approach is that you will be able to move the resulting SBCL binary to any Windows machine.
The article consists of three parts:
Start by downloading the latest installer of MSYS2. I recommend the 64 bits version, named msys2-x86_64-yyyy if you have a 64 bits Windows installation. Once the download is finished, start the installer and accept the defaults, you should end up with an MSYS command prompt window.
In the MSYS2 command prompt window or terminal, write:
and respond with Y when asked for confirmation. The above command will update the installation. Close the console window when the update is finished and reopen it from the Windows start menu. Be sure to pick the entry that reads MSYS2 MSYS from the start menu. Repeat the above command to finalize the update process:
Once the above is finished, we are ready to install the GCC toolchain:
Next, install the bzip2 utility:
Close the MSYS2 command prompt by writing:
Go to the SBCL download page and get the latest Windows 64 bits binary. At the time of this writing, latest SBCL binary is 1.4.14. This is a typical Windows installer.
Be sure to modify the default install location in order to not contain any spaces and to disable the add SBCL to the Windows PATH:
As you can see, from the above image, I’ve chosen to install SBCL to C:\DEV\SBCL-1.4.4. Feel free to use a different location, as long as there are no spaces in the install path. I’ve also disabled the add SBCL to the Windows PATH and the creation of the SBCL_HOME environment variable, this is necessary in order to not interfere with the SBCL build from the next part of the tutorial.
After the above customization, you can accept all the installer defaults.
Use the Windows start menu to open a MinGW 64 command prompt, pick the entry that reads MSYS2 MinGW 64-bit and download the SBCL source file:
Once the download is finished, extract the archive:
Next, temporarily add to the path the official SBCL binary and create the SBCL_HOME environment variable:
Please note, that in the above I assumed that you’ve installed the official SBCL binary to C:\DEV\SBCL-1.4.4. If you’ve used a different install location, modify the above command accordingly.
Next, create a temporary environment variable named GNUMAKE that points to the mingw32-make utility:
At this point, we are ready to build the latest SBCL. For simplicity, I will install SBCL to C:\SBCL-1.5.5. Again feel free to use a different location as long as you have no spaces in the install path, you will also need to modify the next commands accordingly if you want to use a different install path:
If there are no build errors, you can install SBCL:
Next, you can optionally add the newly built SBCL to the MSYS2 path:
With the above you should have the sbcl available from a MinGW command prompt.
It is probably easier and more portable to create a Windows batch file that sets the above environment variables. Create a text file named open_cmd.bat in C:\SBCL-1.5.5 and copy the next commands to it:
The above will let you double click on open_cmd.bat which will temporarily add SBCL to the PATH and open a command window in which you can use the sbcl executable. It is also possible to add the above to the Windows PATH permanently, but I suggest to use the batch file approach in order to not mess the Windows PATH.
If you want to get a SBCL REPL double click on open_cmd.bat and write sbcl. If you have a .lisp file, e.g. my_script.lisp, that you want to run, you could use:
If you want to copy the resulting binary to a different Windows machine, simply copy the SBCL-1.5.5 folder to the new machine. No need to install MSYS2 to the new machine.