While trying to install "hunchentoot" via (ql:quickload :hunchentoot)
, an error is produced:
debugger invoked on a CFFI:LOAD-FOREIGN-LIBRARY-ERROR in thread
#<THREAD "main thread" RUNNING {9461061}>:
Unable to load any of the alternatives:
("libcrypto.so.1.1" "libcrypto.so.1.0.0" "libcrypto.so.3" "libcrypto.so")
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [RETRY ] Try loading the foreign library again.
1: [USE-VALUE ] Use another library instead.
2: [TRY-RECOMPILING ] Recompile reload and try loading it again
3: ...
...
But I already have the mentioned libraries installed. So, I tried to manually point CFFI to the installed libraries:
* (cffi::load-foreign-library "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1")
debugger invoked on a CFFI:LOAD-FOREIGN-LIBRARY-ERROR in thread
#<THREAD "main thread" RUNNING {9461061}>:
Unable to load foreign library (LIBCRYPTO.SO.1.1-554).
Error opening shared object "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1":
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: wrong ELF class: ELFCLASS64.
But it results in this "wrong ELF" error.
My system is a 64-bit Ubuntu 20.04.6
(update: Most likely, it was the fact that I accidentally installed the 32-bit version of the SBCL on my 64-bit machine, by confusing the x86 mentioned on the SBCL download page for x86_64 (mentioned on the page as AMD64). Most of the issues related to CFFI-loading foreign libraries went away after I installed the AMD64 version, but in case the answer below if useful to some, I'll leave it as is.)
———— Original answer: ————
I was able to solve this by manually installing the 32-bit version of OpenSSL-1.1.1 and running sudo ldconfig
to update the cache of links pointing to the shared libraries that the service responsible for CFFI-loading foreign libraries references.
— Install dependencies for compiling a program to run on a different processor architecture:
sudo apt-get install build-essential
sudo apt-get install gcc-multilib g++-multilib
— Download the source code for OpenSSL-1.1.1:
wget https://www.openssl.org/source/openssl-1.1.1.tar.gz
^^ alternatively, download from the Github releases
— Unarchive the downloaded code and navigate to its directory:
tar -xvzf openssl-1.1.1.tar.gz
cd openssl-1.1.1
— Configure the build tools to compile the code for a 32-bit architecture and install:
./Configure linux-generic32
make CC="gcc -m32" CXX="g++ -m32"
sudo make install
— Update the cache of the shared libraries used by dynamic linker/loader:
sudo ldconfig
After performing all of the above, I was able to run (ql:quickload :hunchentoot)
inside the sbcl
REPL without it producing any errors.