Unable to load foreign library (LIBZMQ)
hufengtao opened this issue · comments
hufengtao commented
sbcl 2.0.9
(ql:quickload "pzmq")
libzmq.so installed under path /usr/local/lib
zmq.h installed under path /usr/local/include
Error opening shared object "libzmq.so":
libzmq.so: cannot open shared object file: No such file or directory.
Orivej Desh commented
This is an issue about configuring CFFI to look in /usr/local/lib and /usr/local/include.
-
If you can edit the file
sbcl.mk
in your(uiop:lisp-implementation-directory)
, then add-L/usr/local/lib
to its LDFLAGS and-I/usr/local/include
to its CFLAGS, and restart sbcl. -
Otherwise try this before loading pzmq:
(ql:quickload "cffi")
(push #p"/usr/local/lib/" cffi:*foreign-library-directories*)
(push "-I/usr/local/include" cffi-toolchain:*cc-flags*)
(You can put this code into ~/.sbclrc
to perform it on sbcl startup.)
- If you do not want to configure CFFI in Lisp or via sbcl.mk, you can add /usr/local/lib to LD_LIBRARY_PATH or /etc/ld.so.conf, but AFAIK there is no way to use /usr/local/include. (cffi/cffi#146 could have allowed you to export CFLAGS=/usr/local/include.)