JNA UnsatisfiedLinkError, but jna.library.path is set

后端 未结 6 1567
囚心锁ツ
囚心锁ツ 2020-12-16 19:50

I\'m using the following code to load a dll in JNA (irrelevant code is left out):

    public class JNAMain {
       public interface PointShapeBuffer extends         


        
6条回答
  •  醉酒成梦
    2020-12-16 20:21

    Change your:

    Native.loadLibrary("FileGDBAPI", PointShapeBuffer.class);
    

    to:

    Native.loadLibrary("C:\\jnadll\\FileGDBAPI.dll", PointShapeBuffer.class);
    

    If you dive into the jna source code enough you will find a nice little hook in the NativeLibrary class:

        /** Use standard library search paths to find the library. */
        private static String findLibraryPath(String libName, List searchPath) {
            //
            // If a full path to the library was specified, don't search for it
            //
            if (new File(libName).isAbsolute()) {
                return libName;
            }
            ...
    

    So it will catch if you just passed an absolute path and not even use the searchPath. This was why you dont have to worry about jna.library.lib.

提交回复
热议问题