Re: How to load the jna jar file before cffi?

Mark Evenson <[email protected]>
Newsgroups gmane.editors.j.devel
Message-ID <[email protected]>

On 5/10/17 22:24, Mirko Vukovic wrote:
> Hello,
> 
> In order for CFFI to load, I need to load jna-4.2.2.jar.
> 
> Right now, I have to do something like this:
> (let ((jar-pathname
> #P"c:/Users/977315/.m2/repository/net/java/dev/jna/jna/4.2.2/jna-4.2.2.jar"))
>   (java:add-to-classpath (namestring jar-pathname)))
> 
> To automate loading of ASDFs that require CFFI I tried to automate the
> process by adding a before method to 'load-op:
> 
> (eval-when (:compile-toplevel :execute :load-toplevel)
>   (defmethod operate :before ((operation (eql 'asdf/lisp-action:load-op))
> (component (eql :cffi)))
>     (let ((jar-pathname
> #P"c:/Users/977315/.m2/repository/net/java/dev/jna/jna/4.2.2/jna-4.2.2.jar"))
>       (java:add-to-classpath (namestring jar-pathname)))))
> 
> That did not work.  I did read the ASDF manual, but could not figure out
> how to do it.
> 
> I suspect someone has figured out the right way.  What is it?

Such "manual" loading of the JNA should be not be necessary in the
default case of using ABCL-ASDF's Maven integration to download from the
network, which is what [the ABCL specific portion of][cffi] does.

[cffi]: https://github.com/cffi/cffi/blob/master/src/cffi-abcl.lisp#L37

The

  (require :jna)

refers to the [jna.asd][] definition, which is then passed to ABCL-ASDF
for resolution.

[jna.asd]:
https://gitlab.common-lisp.net/abcl/abcl/blob/master/contrib/mvn/jna.asd

"All" that you need to do to get this to work is to have a version of
Maven installed.  The [ABCL-ASDF][1] code should find the Maven
executable in the JVM process path with which it will introspect the
necessary operations needed to use the Mavane Aether infrastructure.

[1]:
https://gitlab.common-lisp.net/abcl/abcl/blob/master/contrib/abcl-asdf/maven-embedder.lisp

To go forward with your problems:

1.  Do you have Maven installed or is there some reason in your
deployment scenario that you do not wish to use it?

2.  Without trying to load CFFI, does the following form load JNA from a
fresh REPL?

  (require :abcl-contrib)
  (require :jna)


-- 
"A screaming comes across the sky.  It has happened before, but there
is nothing to compare to it now."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.