Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
621 views
in Technique[技术] by (71.8m points)

java - JPL/SWI Prolog configuration failure

I'm configuring the JPL right now, and wanna work with swi-prolog using java.

I downloaded the newest stable version of SWI-Prolog, which is 6.2.0, and installed in D:swipl

First, I added the following path to the PATH virable: D:swiplin, which should include all dll files needed.

Then, I added the following path to the CLASSPATH virable: D:swipllibjpl.jar, which should be the jar file needed.

When I tried to run the versions example provided, I got the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I
    at jpl.fli.Prolog.thread_self(Native Method)
    at jpl.Query.open(Query.java:286)
    at jpl.Util.textToTerm(Util.java:162)
    at jpl.Query.Query1(Query.java:183)
    at jpl.Query.<init>(Query.java:176)
    at Versions.main(Versions.java:11)

After searching online, I found that many people just get java.lang.UnsatisfiedLinkError: no jpl in java.library.path which is because of the setting for the PATH variable, rather than the error I get here: java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I (and yes, there is a "I" at the end of the line).

Has anyone gotten this error before? I've tried several previous version of SWI-Prolog, but also got other kinds of errors. I'm using Eclipse IDE for Java development -- have I missed anything?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I've sent the problem to the official mailing list ([email protected]) provided by swi-prolog.org, and luckily someone helped me to prove that there are some problems in the version 6.2.0. We then both tried the version 6.0.2, and it works perfectly. He mentioned that (and I noticed that) there is no swipl.dll in the bin folder of the version 6.2.0, which MAY causes the issue.

I've already reported the issue to the staff via Email, and at least for now, I suggest that people who want to configure JPL should download the version 6.0.2. Three things to remember:

  1. add a new variable SWI_HOME_DIR under system variables in environment variables, and set the path to the place where you installed the SWI-Prolog (Mine is D:swipl);

  2. Add the path %SWI_HOME_DIR%in to your PATH variable, rather than use something like "D:swiplin". (Otherwise [FATAL ERROR: Could not find system resources] will occur)

  3. Add the path %SWI_HOME_DIR%libjpl.jar to your PATH variable, rather than use something like "D:swipllibjpl.jar". (Otherwise [FATAL ERROR: Could not find system resources] will occur)

If you are using Eclipse for Java development, it seems that you DO NOT need to configure in your IDE. As long as you follow the 3 steps above and add the correct jar file as an external library, it should be fine.

I'm not sure whether the temporary solution works for everyone, but definitely, everyone who has the issue should try this method first. As long as the issue in the version 6.2.0 has been figured out, I'll add some comments here.

BTW, as far as I know, until now, people who have the issue are using 32-bit Windows.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...