[pHash-support] Java usage of pHash.java

Evan Klinger eklinger at phash.org
Mon Jan 11 11:00:33 PST 2010


Sebastian,
It looks like the entire API might need to be wrapped in extern "C" to
get this to work. To be honest, you're the first that is attempting to
use the Java bindings so it's a learning process for both of us. There
is an example on how to use the functions in pHash.java in main(). Try
adding the extern "C" to all the functions in pHash.h and rebuild and
see if that helps. Sorry for the trouble.
Thanks

On Mon, Jan 11, 2010 at 9:30 AM, Sebastian Gallese
<sebastiangallese at gmail.com> wrote:
> Hi Evan,
>
> I'm unsure of how I should use pHash with Java.  Do you have some
> basic test code or demo code to show me the basic usage?
>
> For example, right now I'm trying to call on pHash to get a hash from an image.
>
> I threw the file from pHash-0.7.2/bindings/java/pHash.java into a
> package in Eclipse.
>
> http://github.com/sgallese/sgallese/tree/master/src/pHashTest/
>
> As you can see from the above code, I have phash.java side by side
> with PHashTest.java in a package caled pHashTest
>
> In PHashTest.java, I just wanted to instantiate pHash, so I have the
> following code:
>
> package pHashTest;
>
>        public class PHashTest {
>            public static void main(String[] args) {
>                pHash mypHash = new pHash();
>            }
>        }
>
> I kept getting the error "java.lang.UnsatisfiedLinkError: no pHash-jni
> in java.library.path" so I searched for pHash-jni on my system and
> found these:
>
> /usr/local/include/pHash-jni.h
> /usr/local/lib/libpHash-jni.so
> /usr/local/lib/libpHash-jni.so.0
> /usr/local/lib/libpHash-jni.so.0.0.0
> /usr/local/lib/libpHash-jni.la
> /usr/local/lib/libpHash-jni.a
>
> In Eclipse, I then went to run -> run configurations -> Environment
> (tab) and I set LD_LIBRARY_PATH to /usr/local/lib/
>
> Then I tried to initiate a pHash object again (i.e., pHash mypHash =
> new pHash(); ) and I'd get the following error.
>
> Exception in thread "main" java.lang.UnsatisfiedLinkError:
> /usr/local/lib/libpHash-jni.so.0.0.0:
> /usr/local/lib/libpHash-jni.so.0.0.0: undefined symbol:
> _ZL17ph_free_datapointP12ph_datapoint
>        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
>        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1778)
>        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
>        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
>        at java.lang.System.loadLibrary(System.java:1028)
>        at pHashTest.pHash.<clinit>(pHash.java:47)
>        at pHashTest.PHashTest.main(PHashTest.java:6)
>
> I figured I'd then try to make an ImageHash object using the code
>
> ImageHash mypHash = new ImageHash("/home/kdge/Pictures/cc.jpg");
>
> but ImageHash would not take a string in its constructor.
>
> Any help is greatly appreciated!
>
> Thanks,
>
> Seb
> _______________________________________________
> pHash-support mailing list
> pHash-support at lists.phash.org
> http://lists.phash.org/listinfo.cgi/phash-support-phash.org
>



More information about the pHash-support mailing list