How to load a dylib from a particular place
![](https://secure.gravatar.com/avatar/4b9de6a4e61210fb419beb9daed3eb4f.jpg?s=120&d=mm&r=g)
I sent this email earlier, but then realized I was not subscribed. So I have know way of knowing whether it got spam-filtered out. So here it is again. Sorry if this is a repeat question. The program I'm trying to load has several dependencies which I'm still trying to figure out. One problem (I think) is that it loading some of its .dylib libraries from the wrong place. I'd like to load them explicitly to help me debug the problem. What is the correct way to do this. Here's what I've tried (but it is not yet correct). I've added the line to my .sbclrc file. (cffi:load-foreign-library "/usr/local/Cellar/cairo/1. 12.16_1/lib/libcairo.dylib") This seems indeed to load the dylib, but later my system calls (CFFI::LOAD-FOREIGN-LIBRARY-PATH :LIBCAIRO "libcairo.dylib" NIL) which apparently does not realise :LIBCAIRO is already loaded, so it tries to load cairo again but from /usr/local/Cellar/cairo/1.14. 6_1/lib/libcairo.2.dylib Is there a way for me to tell cffi:load-foreign-library that loading 1.12.16_1 loads :LIBCAIRO ? I thought about calling cffi:define-foreign-library to associate :LIBCAIRO with the explicit path "/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.dylib", but I don't see how to do that. Can someone help? Thanks. Jim
![](https://secure.gravatar.com/avatar/326b108ffcc42f27628703b0c11ed239.jpg?s=120&d=mm&r=g)
On Thu, Sep 15, 2016 at 4:05 PM, Jim Newton <jimka.issy@gmail.com> wrote:
I sent this email earlier, but then realized I was not subscribed. So I have know way of knowing whether it got spam-filtered out. So here it is again. Sorry if this is a repeat question.
One way to check if your message went through is to check the mailing list archive at <https://mailman.common-lisp.net/pipermail/cffi-devel/>. (It's not repeated. :-))
(cffi:load-foreign-library "/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.dylib")
This seems indeed to load the dylib, but later my system calls (CFFI::LOAD-FOREIGN-LIBRARY-PATH :LIBCAIRO "libcairo.dylib" NIL) which apparently does not realise :LIBCAIRO is already loaded, so it tries to load cairo again but from /usr/local/Cellar/cairo/1.14.6_1/lib/libcairo.2.dylib
Perhaps <https://common-lisp.net/project/cffi/manual/html_node/_002aforeign_002dlibrary_002ddirectories_002a.html> may help? Push #p"/usr/local/Cellar/cairo/1.12.16_1/lib/" onto that variable. Cheers, -- Luís Oliveira http://kerno.org/~luis/
participants (2)
-
Jim Newton
-
Luís Oliveira