Subject: Re: SBCL CFFI from Guix unable to find dynamic libraries

From: Evan Straw <[email-masked]>
Date: Mon, 13 Jan 2020 14:11:53 -0800

Hi Pierre,
Thanks for your response.

>In the meantime, you can add this to your ~/.sbclrc:
>
>--8<---------------cut here---------------start------------->8---
>(when (ignore-errors (asdf:load-system "cffi"))
>  ;; Warning: Trailing "/" matters!
>  (dolist (guix-profile
>           `(,(when (uiop:directory-exists-p "~/.guix-profile")
>                (format nil "~a/.guix-profile/lib/" (uiop:getenv "HOME")))
>              ,@(mapcar (lambda (d)
>                          (format nil "~a~a/lib/"
>                                  (namestring d)
>                                  (first (last (pathname-directory d)))))
>                        (uiop:subdirectories "~/.guix-extra-profiles/"))))
>    (push guix-profile
>          (symbol-value (find-symbol (string '*foreign-library-directories*)
>                                     (find-package 'cffi))))))
>--8<---------------cut here---------------end--------------->8---

I attempted to add this to my .sbclrc, and added the "/usr/lib/x86_64-linux-gnu"
directory to that list as well. This seems to have made some progress, because
now, when I load CFFI, the *foreign-library-directories* variable is populated
with a list of directories. Additionally, CFFI is capable of loading libraries
installed through Guix as well with no issues. 

However, the thing that still doesn't appear to be working right is loading
libraries from the foreign distro. I get the same behavior as before when
attempting to load a library under the foreign distro's library directory
(/usr/lib/x86_64-linux-gnu): It loads the library itself but fails upon trying
to load any dependencies, even if they are in the same directory. Ideally, I
would just install the libraries I need from Guix, but I specifically want to
interface with a library from the system, in this case PulseAudio (I've just
been using libcurl as a test to make sure it works). 

I did some investigation and tried both installing just CFFI from another
source, and then SBCL itself. Installing CFFI from Quicklisp but keeping SBCL
from Guix gave the same behavior and was unable to load dependencies of the
library. Installing SBCL from APT and CFFI from Quicklisp was able to load the
library and all dependencies with no issues. From this, I'm wondering if it's a
problem with SBCL itself instead of CFFI? 

Do you (or anyone reading this thread) have any thoughts on this? Is this a bug
in the SBCL package, and if so, is there any way to work around it currently? 

Thanks for the help.
-- Evan