From: "Sudarshan S Chawathe" <chaw@eip10.org>
To: Kawa mailing list <kawa@sourceware.org>
Subject: Kawa and System.loadLibrary and native code
Date: Sun, 12 May 2019 15:24:00 -0000 [thread overview]
Message-ID: <31621.1557674648@vpaur.eip10.org> (raw)
I am trying to use OpenCV from Kawa using the OpenCV-Java library (which
uses JNI) but cannot seem to get rid of an UnsatisfiedLinkError. I
suspect I am confused about how System.loadLibrary works relative to
class loading in Kawa (or Java for that matter) and would be grateful
for any pointers.
Here is my test code:
(import (class org.opencv.core
Core CvType Mat))
(define (hello)
(java.lang.System:loadLibrary Core:NATIVE_LIBRARY_NAME)
(display ((Mat:eye 3 3 CvType:CV_8UC1):dump))
(newline))
(hello)
Core:NATIVE_LIBRARY_Name evaluates to "opencv_java249" on my setup
(Debian 9) and I am invoking kawa with the following command line
(/usr/lib/jni contains libopencv_java249.so):
java -Djava.library.path="/usr/lib/jni:" kawa.repl \
--output-format readable-scheme $*
Here's the error trace:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
at org.opencv.core.Mat.n_eye(Native Method)
at org.opencv.core.Mat.eye(Mat.java:1467)
at atInteractiveLevel-4.hello(tty:17)
at atInteractiveLevel-4.hello$check(tty:15)
at gnu.mapping.Procedure.applyToConsumerDefault(Procedure.java:75)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:343)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:211)
at kawa.Shell.run(Shell.java:289)
at kawa.Shell.run(Shell.java:196)
at kawa.Shell.run(Shell.java:183)
at kawa.repl.processArgs(repl.java:724)
at kawa.repl.main(repl.java:830)
For reference, here is the Java version, from the opencv-java tutorial,
which works fine. If I comment out the System.loadlibrary line then it
generates an error very similar to what I get from the above Kawa code.
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
public class HelloCV {
public static void main(String[] args){
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
System.out.println("mat = " + mat.dump());
}
}
Regards,
-chaw
reply other threads:[~2019-05-12 15:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=31621.1557674648@vpaur.eip10.org \
--to=chaw@eip10.org \
--cc=kawa@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).