JPL找不到jpl.dll的依赖库 [英] JPL Can't find dependent libraries of jpl.dll

查看:315
本文介绍了JPL找不到jpl.dll的依赖库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的电脑安装SWI-Prolog之后,我继续尝试其中的一个例子,并发现了这个特别的美丽:

  run:
线程main中的异常java.lang.UnsatisfiedLinkError:C:\Program文件(x86)\swipl\bin\jpl.dll:找不到从属库
在java.lang.ClassLoader $ NativeLibrary.load(Native Method)
在java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
在java.lang.ClassLoader.loadLibrary(ClassLoader。 java:1732)
在java.lang.Runtime.loadLibrary0(Runtime.java:823)
在java.lang.System.loadLibrary(System.java:1028)
at jpl.JPL .loadNativeLibrary(JPL.java:100)
at jpl.fli.Prolog。< clinit>(Prolog.java:85)
at jpl.Query.open(Query.java:286)
at jpl.Util.textToTerm(Util.java:162)
at jpl.Query。< init>(Query.java:198)
在main.ProjetoPLP.main(ProjetoPLP.java: 12)
Java结果:1

我已经检查过,并且 在上述文件夹中有一个jpl.dll文件,所以我不知道这里发生了什么。我已经在本网站和互联网上检查了较旧的问题,但没有提供任何确定的答案。



任何人都有任何想法如何去做? p>

编辑:



以下是我试图运行的代码,以防有助于。

  package main; 
import java.io. *;
import java.util.Hashtable;
import jpl.Query;
import org.apache.commons.io。*;

public class ProjetoPLP
{

private static void loadJPLDll(){
try {
InputStream in = ProjetoPLP.class.getResourceAsStream /test/resources/jpl.dll);
文件fileOut = new File(jpl.dll);
OutputStream out = FileUtils.openOutputStream(fileOut);
IOUtils.copy(in,out);
in.close();
out.close();
System.load(fileOut.getAbsolutePath()); //加载到这里
} catch(Exception e){
e.printStackTrace();
}
}
public static void
main(String args [])
{

loadJPLDll();
String t1 =consult('family.pl');
查询q1 = new Query(t1);

System.out.println(t1 ++(q1.hasSolution()?succeeded:failed));

// ---------------------------------------- ----------

字符串t2 =child_of(joe,ralf);
查询q2 =新查询(t2);

System.out.println(t2 +is+(q2.hasSolution()?可证明:不可证明));

// ---------------------------------------- ----------

String t3 =descendent_of(steve,ralf);
查询q3 = new Query(t3);

System.out.println(t3 +is+(q3.hasSolution()?可证明:不可证明));

// ---------------------------------------- ----------

String t4 =descendent_of(X,ralf);
查询q4 = new Query(t4);

System.out.println(+ t4 +的第一个解决方案:X =+ q4.oneSolution()。get(X));

// ---------------------------------------- ----------

Hashtable [] ss4 = q4.allSolutions();

System.out.println(所有解决方案+ t4); (int i = 0; i< ss4.length; i ++){
System.out.println(X =+ ss4 [i] .get(X));

}

// ----------------------------------- ---------------

System.out.println(每个解决方案+ t4);
while(q4.hasMoreSolutions()){
java.util.Hashtable s4 = q4.nextSolution();
System.out.println(X =+ s4.get(X));
}

// ----------------------------------- ---------------

String t5 =descendent_of(X,Y);
查询q5 = new Query(t5);

System.out.println(每个解决方案+ t5);
while(q5.hasMoreSolutions()){
java.util.Hashtable s5 = q5.nextSolution();
System.out.println(X =+ s5.get(X)+,Y =+ s5.get(Y));
}

}

}


解决方案

如果您在该位置安装了swi-prolog,则Windows更改环境路径设置并添加C:\Program Files(x86)\swipl\bin。或者,dll文件可以如下所示加载。

  private static void loadDLL(String location){
try {
文件dll = new File(location);
System.load(dll.getAbsolutePath());
} catch(Exception e){
e.printStackTrace();
}
}

public static void main(String [] args){
//加载依赖的dll文件
loadDLL(libwinpthread-1 .DLL);
loadDLL(libgcc_s_sjlj-1.dll);
loadDLL(libgmp-10.dll);
loadDLL(libswipl.dll);
loadDLL(json.dll);
loadDLL(jpl.dll);

//您的代码
}

您将需要如果使用上述代码,则为附加的JPL.jar文件添加本机库位置。您可以按照如何从Eclipse设置java.library.path


After installing SWI-Prolog in my computer, I went on to try one of its examples, and found out this particular beauty:

run:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files (x86)\swipl\bin\jpl.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1732)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at jpl.JPL.loadNativeLibrary(JPL.java:100)
    at jpl.fli.Prolog.<clinit>(Prolog.java:85)
    at jpl.Query.open(Query.java:286)
    at jpl.Util.textToTerm(Util.java:162)
    at jpl.Query.<init>(Query.java:198)
    at main.ProjetoPLP.main(ProjetoPLP.java:12)
Java Result: 1

I've checked, and there is a jpl.dll file inside the aforementioned folder, so I'm not exactly sure what's going on here. I've checked older questions on this website, and the internets, but neither provided any sort of conclusive answer.

Anyone has any idea how to go about this?

EDIT:

Here is the code I'm trying to run, in case that helps.

package main;
import java.io.*;
import java.util.Hashtable;
import jpl.Query;
import org.apache.commons.io.*;

public class ProjetoPLP
{

    private static void loadJPLDll() {
    try {
        InputStream in = ProjetoPLP.class.getResourceAsStream("/test/resources/jpl.dll");
        File fileOut = new File("jpl.dll");
        OutputStream out = FileUtils.openOutputStream(fileOut);
        IOUtils.copy(in, out);
        in.close();
        out.close();
        System.load(fileOut.getAbsolutePath());// loading goes here
    } catch (Exception e) {
        e.printStackTrace();
    }
}
    public static void
    main(String args[] )
    {

                loadJPLDll();
        String t1 = "consult('family.pl')";
        Query q1 = new Query(t1);

        System.out.println( t1 + " " + (q1.hasSolution() ? "succeeded" : "failed") );

        //--------------------------------------------------

        String t2 = "child_of(joe, ralf)";
        Query q2 = new Query(t2);

        System.out.println( t2 + " is " + (q2.hasSolution() ? "provable" : "not provable") );

        //--------------------------------------------------

        String t3 = "descendent_of(steve, ralf)";
        Query q3 = new Query(t3);

        System.out.println( t3 + " is " +(q3.hasSolution() ? "provable" : "not provable") );

        //--------------------------------------------------

        String t4 = "descendent_of(X, ralf)";
        Query q4 = new Query(t4);

        System.out.println( "first solution of " + t4 + ": X = " + q4.oneSolution().get("X"));

        //--------------------------------------------------

        Hashtable[] ss4 = q4.allSolutions();

        System.out.println( "all solutions of " + t4);
        for ( int i=0 ; i<ss4.length ; i++ ) {
            System.out.println( "X = " + ss4[i].get("X"));
        }

        //--------------------------------------------------

        System.out.println( "each solution of " + t4);
        while ( q4.hasMoreSolutions() ){
            java.util.Hashtable s4 = q4.nextSolution();
            System.out.println( "X = " + s4.get("X"));
        }

        //--------------------------------------------------

        String t5 = "descendent_of(X,Y)";
        Query q5 = new Query(t5);

        System.out.println( "each solution of " + t5 );
        while ( q5.hasMoreSolutions() ){
            java.util.Hashtable s5 = q5.nextSolution();
            System.out.println( "X = " + s5.get("X") + ", Y = " + s5.get("Y"));
        }

    }

}

解决方案

For windows change the environment path settings and add C:\Program Files (x86)\swipl\bin if you have swi-prolog installed in that location. Alternatively the dll files can be loaded as shown below.

private static void loadDLL(String location) {
    try {
        File dll = new File(location);
        System.load(dll.getAbsolutePath());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public static void main(String[] args) {
    //load the dependent dll files
    loadDLL("libwinpthread-1.dll");
    loadDLL("libgcc_s_sjlj-1.dll");
    loadDLL("libgmp-10.dll");
    loadDLL("libswipl.dll");    
    loadDLL("json.dll");
    loadDLL("jpl.dll");

    //your code here
}

You will need to add the native library location for the attached JPL.jar file if using the above code. You can follow How to set the java.library.path from Eclipse

这篇关于JPL找不到jpl.dll的依赖库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆