I am trying to use the BLAS/LAPACK libraries from SBCL (specifically trying to get the LLA package running). I was having a lot of troubles getting the BLAS shared library to load; eventually I discovered that it wasn't able to load its dependent libraries. Eventually I was able to load BLAS by loaded all of its dependencies manually:
(setq cffi::*foreign-library-directories* '("C:/cygwin64/bin/" "C:/cygwin64/lib/lapack/"))
(CFFI:LOAD-FOREIGN-LIBRARY "CYGWIN1.DLL")
(CFFI:LOAD-FOREIGN-LIBRARY "CYGGCCC_S-SEH-1.DLL")
[..etc..]
(CFFI:LOAD-FOREIGN-LIBRARY "CYGBLAS-0.dll")
As a workaround this isn't terrible, but I don't understand why CFFI:LOAD-FOREIGN-LIBRARY is not able to find and load the dependencies itself. Am I doing something wrong?
In your case it's probably not CFFI but Windows DLL search rules that make this happen.
As cygblas-0.dll
is in the c:\cygwin64\lib\lapack
directory, any dependencies it may have are searched from that same directory, the current directory, Windows directories, and from PATH
.
If you do not have c:\cygwin64\bin
in your path, the DLLs cannot be found. cffi::*foreing-library-directories*
does not affect the Windows functionality; CFFI simply executes a call to LoadLibrary
with a full path to the DLL.
As a solution, I suggest you configure your PATH
to include the c:\cygwin64\bin
directory, which is a good idea in any case. Alternatively, you could modify the PATH
environment variable in your code before the call to load-foreign-library
, but the way it's done is implementation dependent.