CFFI Not Loading Dependent Libraries?

寵の児 提交于 2019-12-22 10:14:47

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/22213133/cffi-not-loading-dependent-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!