anubhav94 / gstreamer-java

Automatically exported from code.google.com/p/gstreamer-java
0 stars 0 forks source link

java.lang.UnsatisfiedLinkError is ambiguous #141

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install http://docs.gstreamer.com/display/GstSDK/Installing+on+Mac+OS+X
2. Create gstreamer-java 1.6 project
3. Run - will fail with  "java.lang.UnsatisfiedLinkError: Unable to load 
library gstreamer"

What is the expected output? What do you see instead?

It needs to fail with a more informative message. In gstreamer-java 1.5 it 
would fail with:

java.lang.UnsatisfiedLinkError: Unable to load library 'gstreamer-0.10': 
dlopen(libgstreamer-0.10.dylib, 9): image not found

Which told me the exact problem I had - gstreamer for mac names its files 
ending in "-0.10.0" while gstreamer-java expects them to be "-0.10". Manually 
creating symlinks between the files fixes all problems.

Have you tried to verify this is a gstreamer-java specific issue, and not a
problem with the gstreamer framework itself? Yes gstreamer's 
"gst-playback-test-0.10" can correctly launch and play videos without creating 
symlinks.

What version of the product are you using? On what operating system?
Mac OS X 10.7.5, GStreamer 2013.6, gstreamer-java 1.5 / 1.6

Please provide any additional information below.

To "fix" the problem I must do this:

sudo -s
cd /Library/Frameworks/GStreamer.framework/Versions/0.10/lib
ln -s libgstreamer-0.10.0.dylib libgstreamer-0.10.dylib
ln -s libglib-2.0.0.dylib libglib-2.0.dylib
ln -s libgobject-2.0.0.dylib libgobject-2.0.dylib
ln -s libgstinterfaces-0.10.0.dylib libgstinterfaces-0.10.dylib
ln -s libgstbase-0.10.0.dylib  libgstbase-0.10.dylib

I believe the problem is in GstNative.java, specifically:

    public static <T extends Library> T load(String libraryName, Class<T> interfaceClass) {
        for (String format : nameFormats)
            try {
                return GNative.loadLibrary(String.format(format, libraryName), interfaceClass, options);
            } catch (UnsatisfiedLinkError ex) {
                continue;
            }
        throw new UnsatisfiedLinkError("Could not load library: " + libraryName);
    }

I suggest something like this? I'm still not sure it would print a good error 
message, so you may also need to gather the messages of each exception...

    public static <T extends Library> T load(String libraryName, Class<T> interfaceClass) {
        UnsatisfiedLinkError ule = new UnsatisfiedLinkError("Could not load library: " + libraryName);
        for (String format : nameFormats)
            try {
                return GNative.loadLibrary(String.format(format, libraryName), interfaceClass, options);
            } catch (UnsatisfiedLinkError ex) {
               ule.addSuppressed(ex);
            }
        throw ule;
    }

Thanks for making gstreamer-java - its a great library!

Original issue reported on code.google.com by petrib...@gmail.com on 12 Feb 2014 at 3:11