From: Dustin Withers
Subject: CL+SSL on Clozure Common Lisp (OpenMCL) with cffi
Date: 
Message-ID: <390bc521-414d-48cb-8a6b-920837295cee@o6g2000hsd.googlegroups.com>
Hello All,

I'm trying to get CL+SSL working with CCL and I'm having quite a few
problems. CFFI wants to load libssl.so but on OS X it's supposed to be
libssl.dylib. I've followed many different opinions on what I should
put in the cl+ssl .asd file and I've even tried setting it up from the
a cffi-user package like so:

(defpackage :cffi-user
    (:use :common-lisp :cffi))

(in-package :cffi-user)

(cffi:define-foreign-library libssl
	     (:windows "libssl32.dll")
	     (:openmcl "libssl.dylib")
	     (:unix (:or "libssl.so.0.9.8" "libssl.so"))
	     (t (:default "libssl3")))

(cffi:use-foreign-library libssl)

Which give me the error (from slime):

Unable to load any of the alternatives:
   ("libssl.so.0.9.8" "libssl.so")
   [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]

Restarts:
 0: [RETRY] Try loading the foreign library again.
 1: [USE-VALUE] Use another library instead.
 2: [ABORT] Return to SLIME's top level.
 3: [ABORT-BREAK] Reset this process
 4: [ABORT] Kill this process

Backtrace:
  0: (CFFI::HANDLE-LOAD-FOREIGN-LIBRARY-ERROR '(:OR "libssl.so.0.9.8"
"libssl.so") "Unable to load any of the alternatives:~%   ~S"
'("libssl.so.0.9.8" "libssl.so"))
  1: (CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
  2: (CCL::CALL-CHECK-REGS 'CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)

This is the same error message I'm getting when using ASDF to load CL
+SSL. Any ideas on what I should try here? I've
tried :openmcl, :darwin, :darwinx8664-target...

Thanks,
-dustin

From: Michael Weber
Subject: Re: CL+SSL on Clozure Common Lisp (OpenMCL) with cffi
Date: 
Message-ID: <7a7f3eb6-2e1e-4e45-940b-eb6de08514c4@r60g2000hsc.googlegroups.com>
On Dec 10, 6:35 am, Dustin Withers <·········@gmail.com> wrote:
> Hello All,
>
> I'm trying to get CL+SSL working with CCL and I'm having quite a few
> problems. CFFI wants to load libssl.so but on OS X it's supposed to be
> libssl.dylib. I've followed many different opinions on what I should
> put in the cl+ssl .asd file and I've even tried setting it up from the
> a cffi-user package like so:
>
> (defpackage :cffi-user
>     (:use :common-lisp :cffi))
>
> (in-package :cffi-user)
>
> (cffi:define-foreign-library libssl
>              (:windows "libssl32.dll")
>              (:openmcl "libssl.dylib")
>              (:unix (:or "libssl.so.0.9.8" "libssl.so"))
>              (t (:default "libssl3")))
>
> (cffi:use-foreign-library libssl)
>
> Which give me the error (from slime):
>
> Unable to load any of the alternatives:
>    ("libssl.so.0.9.8" "libssl.so")
>    [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
>
> Restarts:
>  0: [RETRY] Try loading the foreign library again.
>  1: [USE-VALUE] Use another library instead.
>  2: [ABORT] Return to SLIME's top level.
>  3: [ABORT-BREAK] Reset this process
>  4: [ABORT] Kill this process
>
> Backtrace:
>   0: (CFFI::HANDLE-LOAD-FOREIGN-LIBRARY-ERROR '(:OR "libssl.so.0.9.8"
> "libssl.so") "Unable to load any of the alternatives:~%   ~S"
> '("libssl.so.0.9.8" "libssl.so"))
>   1: (CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
>   2: (CCL::CALL-CHECK-REGS 'CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
>
> This is the same error message I'm getting when using ASDF to load CL
> +SSL. Any ideas on what I should try here? I've
> tried :openmcl, :darwin, :darwinx8664-target...

Some time ago, I sent a patch to the CL+SSL maintainers, but it seems
it has not been applied.  See below.

Note that you need to do some extra work if you library is in a non-
standard location (/opt/local/lib, etc.).  Check for *foreign-library-
directories* in the CFFI manual, or set (DY)LD_LIBRARY_PATH, etc.

Michael

Index: reload.lisp
===================================================================
RCS file: /project/cl-plus-ssl/cvsroot/cl+ssl/reload.lisp,v
retrieving revision 1.4
diff -u -r1.4 reload.lisp
--- reload.lisp	14 Jul 2007 11:49:29 -0000	1.4
+++ reload.lisp	31 Oct 2007 19:08:22 -0000
@@ -17,6 +17,7 @@

 (cffi:define-foreign-library libssl
   (:windows "libssl32.dll")
+  (:darwin (:or "libssl.0.9.8.dylib" "libssl.dylib"))
   (:unix (:or "libssl.so.0.9.8" "libssl.so"))
   (t (:default "libssl3")))
From: Dustin Withers
Subject: Re: CL+SSL on Clozure Common Lisp (OpenMCL) with cffi
Date: 
Message-ID: <43160795-1eb9-4b06-b116-14ea6dd3af4b@y5g2000hsf.googlegroups.com>
On Dec 10, 2:03 am, Michael Weber <·········@foldr.org> wrote:
> On Dec 10, 6:35 am, Dustin Withers <·········@gmail.com> wrote:
>
>
>
> > Hello All,
>
> > I'm trying to get CL+SSL working with CCL and I'm having quite a few
> > problems. CFFI wants to load libssl.so but on OS X it's supposed to be
> > libssl.dylib. I've followed many different opinions on what I should
> > put in the cl+ssl .asd file and I've even tried setting it up from the
> > a cffi-user package like so:
>
> > (defpackage :cffi-user
> >     (:use :common-lisp :cffi))
>
> > (in-package :cffi-user)
>
> > (cffi:define-foreign-library libssl
> >              (:windows "libssl32.dll")
> >              (:openmcl "libssl.dylib")
> >              (:unix (:or "libssl.so.0.9.8" "libssl.so"))
> >              (t (:default "libssl3")))
>
> > (cffi:use-foreign-library libssl)
>
> > Which give me the error (from slime):
>
> > Unable to load any of the alternatives:
> >    ("libssl.so.0.9.8" "libssl.so")
> >    [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
>
> > Restarts:
> >  0: [RETRY] Try loading the foreign library again.
> >  1: [USE-VALUE] Use another library instead.
> >  2: [ABORT] Return to SLIME's top level.
> >  3: [ABORT-BREAK] Reset this process
> >  4: [ABORT] Kill this process
>
> > Backtrace:
> >   0: (CFFI::HANDLE-LOAD-FOREIGN-LIBRARY-ERROR '(:OR "libssl.so.0.9.8"
> > "libssl.so") "Unable to load any of the alternatives:~%   ~S"
> > '("libssl.so.0.9.8" "libssl.so"))
> >   1: (CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
> >   2: (CCL::CALL-CHECK-REGS 'CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
>
> > This is the same error message I'm getting when using ASDF to load CL
> > +SSL. Any ideas on what I should try here? I've
> > tried :openmcl, :darwin, :darwinx8664-target...
>
> Some time ago, I sent a patch to the CL+SSL maintainers, but it seems
> it has not been applied.  See below.
>
> Note that you need to do some extra work if you library is in a non-
> standard location (/opt/local/lib, etc.).  Check for *foreign-library-
> directories* in the CFFI manual, or set (DY)LD_LIBRARY_PATH, etc.
>
> Michael
>
> Index: reload.lisp
> ===================================================================
> RCS file: /project/cl-plus-ssl/cvsroot/cl+ssl/reload.lisp,v
> retrieving revision 1.4
> diff -u -r1.4 reload.lisp
> --- reload.lisp 14 Jul 2007 11:49:29 -0000      1.4
> +++ reload.lisp 31 Oct 2007 19:08:22 -0000
> @@ -17,6 +17,7 @@
>
>  (cffi:define-foreign-library libssl
>    (:windows "libssl32.dll")
> +  (:darwin (:or "libssl.0.9.8.dylib" "libssl.dylib"))
>    (:unix (:or "libssl.so.0.9.8" "libssl.so"))
>    (t (:default "libssl3")))

I tried doing that definition directly from cffi-user package and I'm
still seeing the same error message.

Could it be a problem with Leopard?

-dustin
From: Frank Goenninger DG1SBG
Subject: Re: CL+SSL on Clozure Common Lisp (OpenMCL) with cffi
Date: 
Message-ID: <lzprxdavkz.fsf@de.goenninger.net>
Dustin Withers <·········@gmail.com> writes:

> On Dec 10, 2:03 am, Michael Weber <·········@foldr.org> wrote:
>> On Dec 10, 6:35 am, Dustin Withers <·········@gmail.com> wrote:
>>
>>
>>
>> > Hello All,
>>
>> > I'm trying to get CL+SSL working with CCL and I'm having quite a few
>> > problems. CFFI wants to load libssl.so but on OS X it's supposed to be
>> > libssl.dylib. I've followed many different opinions on what I should
>> > put in the cl+ssl .asd file and I've even tried setting it up from the
>> > a cffi-user package like so:
>>
>> > (defpackage :cffi-user
>> >     (:use :common-lisp :cffi))
>>
>> > (in-package :cffi-user)
>>
>> > (cffi:define-foreign-library libssl
>> >              (:windows "libssl32.dll")
>> >              (:openmcl "libssl.dylib")
>> >              (:unix (:or "libssl.so.0.9.8" "libssl.so"))
>> >              (t (:default "libssl3")))
>>
>> > (cffi:use-foreign-library libssl)
>>
>> > Which give me the error (from slime):
>>
>> > Unable to load any of the alternatives:
>> >    ("libssl.so.0.9.8" "libssl.so")
>> >    [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
>>
>> > Restarts:
>> >  0: [RETRY] Try loading the foreign library again.
>> >  1: [USE-VALUE] Use another library instead.
>> >  2: [ABORT] Return to SLIME's top level.
>> >  3: [ABORT-BREAK] Reset this process
>> >  4: [ABORT] Kill this process
>>
>> > Backtrace:
>> >   0: (CFFI::HANDLE-LOAD-FOREIGN-LIBRARY-ERROR '(:OR "libssl.so.0.9.8"
>> > "libssl.so") "Unable to load any of the alternatives:~%   ~S"
>> > '("libssl.so.0.9.8" "libssl.so"))
>> >   1: (CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
>> >   2: (CCL::CALL-CHECK-REGS 'CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
>>
>> > This is the same error message I'm getting when using ASDF to load CL
>> > +SSL. Any ideas on what I should try here? I've
>> > tried :openmcl, :darwin, :darwinx8664-target...
>>
>> Some time ago, I sent a patch to the CL+SSL maintainers, but it seems
>> it has not been applied.  See below.
>>
>> Note that you need to do some extra work if you library is in a non-
>> standard location (/opt/local/lib, etc.).  Check for *foreign-library-
>> directories* in the CFFI manual, or set (DY)LD_LIBRARY_PATH, etc.
>>
>> Michael
>>
>> Index: reload.lisp
>> ===================================================================
>> RCS file: /project/cl-plus-ssl/cvsroot/cl+ssl/reload.lisp,v
>> retrieving revision 1.4
>> diff -u -r1.4 reload.lisp
>> --- reload.lisp 14 Jul 2007 11:49:29 -0000      1.4
>> +++ reload.lisp 31 Oct 2007 19:08:22 -0000
>> @@ -17,6 +17,7 @@
>>
>>  (cffi:define-foreign-library libssl
>>    (:windows "libssl32.dll")
>> +  (:darwin (:or "libssl.0.9.8.dylib" "libssl.dylib"))
>>    (:unix (:or "libssl.so.0.9.8" "libssl.so"))
>>    (t (:default "libssl3")))
>
> I tried doing that definition directly from cffi-user package and I'm
> still seeing the same error message.
>
> Could it be a problem with Leopard?
>
> -dustin

Not enough info to say so yet. What is your load path definition for
CFFI? What is the real location of libssl.dylib in the file system?

Frank

-- 

  Frank Goenninger

  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."
From: John Thingstad
Subject: Re: CL+SSL on Clozure Common Lisp (OpenMCL) with cffi
Date: 
Message-ID: <op.t23vrwh5ut4oq5@pandora.alfanett.no>
P� Mon, 10 Dec 2007 06:35:10 +0100, skrev Dustin Withers  
<·········@gmail.com>:

>
> This is the same error message I'm getting when using ASDF to load CL
> +SSL. Any ideas on what I should try here? I've
> tried :openmcl, :darwin, :darwinx8664-target...
>
> Thanks,
> -dustin

Don't know much about this particular system, but look at the *features*  
variable and see what is listed there.

--------------
John Thingstad
From: ········@gmail.com
Subject: Re: CL+SSL on Clozure Common Lisp (OpenMCL) with cffi
Date: 
Message-ID: <80216007-d555-4be3-92e9-fccf516d5cf1@i12g2000prf.googlegroups.com>
On Dec 10, 12:35 am, Dustin Withers <·········@gmail.com> wrote:
> Hello All,
>
> I'm trying to get CL+SSL working with CCL and I'm having quite a few
> problems. CFFI wants to load libssl.so but on OS X it's supposed to be
> libssl.dylib. I've followed many different opinions on what I should
> put in the cl+ssl .asd file and I've even tried setting it up from the
> a cffi-user package like so:
>
> (defpackage :cffi-user
>     (:use :common-lisp :cffi))
>
> (in-package :cffi-user)
>
> (cffi:define-foreign-library libssl
>              (:windows "libssl32.dll")
>              (:openmcl "libssl.dylib")
>              (:unix (:or "libssl.so.0.9.8" "libssl.so"))
>              (t (:default "libssl3")))
>
> (cffi:use-foreign-library libssl)
>
> Which give me the error (from slime):
>
> Unable to load any of the alternatives:
>    ("libssl.so.0.9.8" "libssl.so")
>    [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
>
> Restarts:
>  0: [RETRY] Try loading the foreign library again.
>  1: [USE-VALUE] Use another library instead.
>  2: [ABORT] Return to SLIME's top level.
>  3: [ABORT-BREAK] Reset this process
>  4: [ABORT] Kill this process
>
> Backtrace:
>   0: (CFFI::HANDLE-LOAD-FOREIGN-LIBRARY-ERROR '(:OR "libssl.so.0.9.8"
> "libssl.so") "Unable to load any of the alternatives:~%   ~S"
> '("libssl.so.0.9.8" "libssl.so"))
>   1: (CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
>   2: (CCL::CALL-CHECK-REGS 'CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
>
> This is the same error message I'm getting when using ASDF to load CL
> +SSL. Any ideas on what I should try here? I've
> tried :openmcl, :darwin, :darwinx8664-target...
>
> Thanks,
> -dustin

I think I had this same problem using OpenMCL.  This is my vague
recollection of the fix.

After tracing the error, I realized that the value of *cffi-feature-
suffix-map* didn't work under the combination of OpenMCL + Mac OS X +
Intel processor (btw, I'm running Leopard as well).  In the CFFI src
file "libraries.lisp", change the defparameter *cffi-feature-suffix-
map* to be:

(defparameter *cffi-feature-suffix-map*
  '((cffi-features:windows . ".dll")
    (cffi-features:darwin . ".dylib")
    (cffi-features:x86-64 . ".dylib")
    (cffi-features:unix . ".so"))
  "Mapping of OS feature keywords to shared library suffixes.")

I didn't keep the original code (which I know is bad), but I believe
it had x86:64 associated with ".so".  That mapping makes sense when
x86-64 identifies (I'm guessing here) an OpenMCL + Linux combination.
But the normal Mac OS X mapping, i.e. cffi-features:darwin .
".dylib"), doesn't seem to work under OpenMcl + Mac OS X + intel
processor.

I don't believe what I'm suggesting is the "correct" way to fix the
problem, but it worked for me.  The suggested fix is not good because
when I upgrade to a new version of CFFI, I'll have to remember to make
the same change.  I guess I should say something to the CFFI guys.

I hope that helps.
--
AF
From: Frank Goenninger DG1SBG
Subject: Re: CL+SSL on Clozure Common Lisp (OpenMCL) with cffi
Date: 
Message-ID: <lzlk80byvu.fsf@de.goenninger.net>
········@gmail.com writes:

> On Dec 10, 12:35 am, Dustin Withers <·········@gmail.com> wrote:
>> Hello All,
>>
>> I'm trying to get CL+SSL working with CCL and I'm having quite a few
>> problems. CFFI wants to load libssl.so but on OS X it's supposed to be
>> libssl.dylib. I've followed many different opinions on what I should
>> put in the cl+ssl .asd file and I've even tried setting it up from the
>> a cffi-user package like so:
>>
>> (defpackage :cffi-user
>>     (:use :common-lisp :cffi))
>>
>> (in-package :cffi-user)
>>
>> (cffi:define-foreign-library libssl
>>              (:windows "libssl32.dll")
>>              (:openmcl "libssl.dylib")
>>              (:unix (:or "libssl.so.0.9.8" "libssl.so"))
>>              (t (:default "libssl3")))
>>
>> (cffi:use-foreign-library libssl)
>>
>> Which give me the error (from slime):
>>
>> Unable to load any of the alternatives:
>>    ("libssl.so.0.9.8" "libssl.so")
>>    [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
>>
>> Restarts:
>>  0: [RETRY] Try loading the foreign library again.
>>  1: [USE-VALUE] Use another library instead.
>>  2: [ABORT] Return to SLIME's top level.
>>  3: [ABORT-BREAK] Reset this process
>>  4: [ABORT] Kill this process
>>
>> Backtrace:
>>   0: (CFFI::HANDLE-LOAD-FOREIGN-LIBRARY-ERROR '(:OR "libssl.so.0.9.8"
>> "libssl.so") "Unable to load any of the alternatives:~%   ~S"
>> '("libssl.so.0.9.8" "libssl.so"))
>>   1: (CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
>>   2: (CCL::CALL-CHECK-REGS 'CFFI:LOAD-FOREIGN-LIBRARY 'LIBSSL)
>>
>> This is the same error message I'm getting when using ASDF to load CL
>> +SSL. Any ideas on what I should try here? I've
>> tried :openmcl, :darwin, :darwinx8664-target...
>>
>> Thanks,
>> -dustin
>
> I think I had this same problem using OpenMCL.  This is my vague
> recollection of the fix.
>
> After tracing the error, I realized that the value of *cffi-feature-
> suffix-map* didn't work under the combination of OpenMCL + Mac OS X +
> Intel processor (btw, I'm running Leopard as well).  In the CFFI src
> file "libraries.lisp", change the defparameter *cffi-feature-suffix-
> map* to be:
>
> (defparameter *cffi-feature-suffix-map*
>   '((cffi-features:windows . ".dll")
>     (cffi-features:darwin . ".dylib")
>     (cffi-features:x86-64 . ".dylib")
>     (cffi-features:unix . ".so"))
>   "Mapping of OS feature keywords to shared library suffixes.")
>
> I didn't keep the original code (which I know is bad), but I believe
> it had x86:64 associated with ".so".  That mapping makes sense when
> x86-64 identifies (I'm guessing here) an OpenMCL + Linux combination.
> But the normal Mac OS X mapping, i.e. cffi-features:darwin .
> ".dylib"), doesn't seem to work under OpenMcl + Mac OS X + intel
> processor.
>
> I don't believe what I'm suggesting is the "correct" way to fix the
> problem, but it worked for me.  The suggested fix is not good because
> when I upgrade to a new version of CFFI, I'll have to remember to make
> the same change.  I guess I should say something to the CFFI guys.
>
> I hope that helps.
> --
> AF

Sort of ;-)

I am on both Tiger and Leopard here and I just use

(eval-when (:load-toplevel :compile-toplevel :execute)
  (progn
     (defmacro ensure-variable (var-name default-value)
       (let ((envvar-value (gensym)))
        `(progn
	   (let ((,envvar-value (getenv (symbol-name ,var-name))))
	     (defparameter ,var-name nil)
	     (when ,envvar-value
	       (setf ,var-name ,envvar-value))
	     (unless ,var-name
	       (setf ,var-name ,default-value))
	     ',var-name))))

    (let ((PMIO_HOME nil))
      (ensure-variable PMIO_HOME "/opt/pmio/")

      (pushnew (pathname (conc$ PMIO_HOME "lib/"))
	       cffi::*foreign-library-directories*
               :test #'equal)
      (format t "~%*** Lib search dirs are: ~A"
	      cffi::*foreign-library-directories*)
      
      (define-foreign-library LIBPMIO
				(:darwin (:or "libpmio.dylib"
                      "~/projects/gt/libpmio/build/Debug/libpmio.dylib"))))))

The above code works for both Tiger and Leopard and for all
implementations ...

Cheers

  Frank

-- 

  Frank Goenninger

  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."