[cffi-devel] CFFI fails to load libs on 64bit machine
![](https://secure.gravatar.com/avatar/0762d4d79abbefc81f80c09301e08f36.jpg?s=120&d=mm&r=g)
Hello, i'am using the CFFI on 32-bit machines without any problem. Switching to a 64-bit platform breaks the loading of a lib. uname -a: Linux master 2.6.8-24-smp #1 SMP Wed Oct 6 09:16:23 UTC 2004 x86_64 x86_64 x86_64 GNU/Linux /etc/SuSE-release: SuSE Linux 9.2 (x86-64) VERSION = 9.2 sbcl: SBCL 0.9.11 library: libgslcblas.so.0 (libc6,x86-64) => /usr/lib/libgslcblas.so.0 libgslcblas.so (libc6,x86-64) => /usr/lib/libgslcblas.so libgsl.so.0 (libc6,x86-64) => /usr/lib/libgsl.so.0 libgsl.so (libc6,x86-64) => /usr/lib/libgsl.so ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; The small lisp prog: (defpackage :cffi-user (:use :common-lisp :cffi)) (in-package :cffi-user) (pushnew #P"/usr/local/lib/" *foreign-library-directories* :test #'equal) ; alternative 1 (define-foreign-library libgslcblas (:unix (:or "libgslcblas.so.0.0.0" "libgslcblas.so.0")) (t (:default "libgslcblas"))) ; alternative 2 (define-foreign-library libgslcblas (t (:default "libgslcblas"))) (use-foreign-library libgslcblas) <---the error happens here (define-foreign-library libgsl (:unix (:or "libgsl.so.0.9.0" "libgsl.so.0")) (t (:default "libgsl"))) (use-foreign-library libgsl) ;;;; (defcfun "gsl_sf_bessel_J0" :double (x :double)) (time (format t "~A~%" (gsl-sf-bessel-J0 5d0))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END The error message: Unable to load foreign library: libgslcblas.so [Condition of type LOAD-FOREIGN-LIBRARY-ERROR] 0: (CFFI::HANDLE-LOAD-FOREIGN-LIBRARY-ERROR "libgslcblas.so" "Unable to load foreign library: ~A" "libgslcblas.so") It doesn't matter if i use alternative 1 or 2. Is it a general matter that CFFI cannot handle 64-bit libs ? Regards Heiko
![](https://secure.gravatar.com/avatar/9ed6ab1d1019fe41799ee83440518e36.jpg?s=120&d=mm&r=g)
Heiko Schroeter <schroete@iup.physik.uni-bremen.de> writes:
i'am using the CFFI on 32-bit machines without any problem. Switching to a 64-bit platform breaks the loading of a lib.
[snip]
Unable to load foreign library: libgslcblas.so [Condition of type LOAD-FOREIGN-LIBRARY-ERROR] 0: (CFFI::HANDLE-LOAD-FOREIGN-LIBRARY-ERROR "libgslcblas.so" "Unable to load foreign library: ~A" "libgslcblas.so")
It doesn't matter if i use alternative 1 or 2.
Is it a general matter that CFFI cannot handle 64-bit libs ?
No, my primary Linux box is an Ubuntu amd64 machine, and it does work for me. Just to make sure, you are using an x86-64 SBCL? (what does (MACHINE-TYPE) return?) Also, what about trying: (sb-alien:load-shared-object "libgslcblas.so") directly? James
![](https://secure.gravatar.com/avatar/0762d4d79abbefc81f80c09301e08f36.jpg?s=120&d=mm&r=g)
James Bielman <jamesjb <at> jamesjb.com> writes:
Heiko Schroeter <schroete <at> iup.physik.uni-bremen.de> writes:
i'am using the CFFI on 32-bit machines without any problem. Switching to a 64-bit platform breaks the loading of a lib.
[snip]
Unable to load foreign library: libgslcblas.so [Condition of type LOAD-FOREIGN-LIBRARY-ERROR] 0: (CFFI::HANDLE-LOAD-FOREIGN-LIBRARY-ERROR "libgslcblas.so"
"Unable to load
foreign library: ~A" "libgslcblas.so")
It doesn't matter if i use alternative 1 or 2.
Is it a general matter that CFFI cannot handle 64-bit libs ?
No, my primary Linux box is an Ubuntu amd64 machine, and it does work for me. Just to make sure, you are using an x86-64 SBCL? (what does (MACHINE-TYPE) return?) Also, what about trying:
This might be the error: (machine-type) returns "X86" !!! Funny enough though.
(sb-alien:load-shared-object "libgslcblas.so")
directly?
Returns an error that the lib cannot be loaded: libgslcblas cannot be found. Will try to get a 64Bit SBCL up and running first. Thanks for the hint. Heiko
![](https://secure.gravatar.com/avatar/9ed6ab1d1019fe41799ee83440518e36.jpg?s=120&d=mm&r=g)
Heiko Schroeter <schroete@iup.physik.uni-bremen.de> writes:
No, my primary Linux box is an Ubuntu amd64 machine, and it does work for me. Just to make sure, you are using an x86-64 SBCL? (what does (MACHINE-TYPE) return?) Also, what about trying:
This might be the error: (machine-type) returns "X86" !!! Funny enough though.
Yeah, you can't load 64-bit libraries into a 32-bit SBCL, but if you have the 32-bit libraries (in /usr/lib32 or /usr/local/lib32 probably) then CFFI should find them. James
![](https://secure.gravatar.com/avatar/0762d4d79abbefc81f80c09301e08f36.jpg?s=120&d=mm&r=g)
James Bielman <jamesjb <at> jamesjb.com> writes:
Yeah, you can't load 64-bit libraries into a 32-bit SBCL, but if you have the 32-bit libraries (in /usr/lib32 or /usr/local/lib32 probably) then CFFI should find them.
James
Just changed to 64Bit sbcl and it works now ! Thanks for the help and sorry for my blindness. Will now have a short sharp trip to "admin" land and.... Heiko
participants (2)
-
Heiko Schroeter
-
James Bielman