Question

I am working on a java project where I am using mediainfo libraries. My JNA code with midiainfo.dll in windows works fine, but when I run my code in linux it is not working and giving following exception -

java.lang.UnsatisfiedLinkError: Unable to load library 'MediaInfo': libMediaInfo.so: cannot open shared object file: No such file or directory

I have written my jave code like this -

interface MediaInfoDLL_Internal extends Library
{

    MediaInfoDLL_Internal INSTANCE = (MediaInfoDLL_Internal) Native.loadLibrary("MediaInfo", MediaInfoDLL_Internal.class, singletonMap(OPTION_FUNCTION_MAPPER, new FunctionMapper()
        {

            public String getFunctionName(NativeLibrary lib, Method method)
            {
                // MediaInfo_New(), MediaInfo_Open() ...
                return "MediaInfo_" + method.getName();
            }
        }
    ));


    //Constructor/Destructor
    Pointer New();
    void Delete(Pointer Handle);

    //File
    int Open(Pointer Handle, WString file);
    void Close(Pointer Handle);

    //Infos
    WString Inform(Pointer Handle);
    WString Get(Pointer Handle, int StreamKind, int StreamNumber, WString parameter, int infoKind, int searchKind);
    WString GetI(Pointer Handle, int StreamKind, int StreamNumber, int parameterIndex, int infoKind);
    int     Count_Get(Pointer Handle, int StreamKind, int StreamNumber);

    //Options
    WString Option(Pointer Handle, WString option, WString value);
}

and just by adding mediainfo.dll in classpath this is working like magic, but in linux i have tried to add libmediainfo.so.0, libmediainfo.so.0.0.0, libzen.so.0 and libzen.so.0.0.0 but no luck...

Does anybody know how to run mediainfo+java in linux?

I m using Java 6, CentOS 5.6 final and latest mediainfo version.

Was it helpful?

Solution 3

I solved my problem by making symlink

I have used following commands from superuser

$ sudo ln -s /usr/lib/libmediainfo.so.0 /usr/lib/libMediaInfo.so
$ sudo ln -s /usr/lib/libzen.so.0 /usr/lib/libzen.so

OTHER TIPS

File names on *nix are case sensitive, so if your library is called libmediainfo.so, you need to change

Native.loadLibrary("MediaInfo",....

to

Native.loadLibrary("mediainfo",

1) Make sure the file is actually called "libMediaInfo.so" (case sensitive!); it can be a symlink pointing to actual version, lots of libs are setup like that. 2) Make sure this file is in LD_LIBRARY_PATH on *nix 3) Making it low case in the code will probably make it a bit cleaner, but that's a matter of style - important thing is lib name in the code must correspond to file name on the system, including case

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top