1
votes

Hi i have a problem with a jpl interface. I want connect JPL with swi-prolog installed with mac-ports with eclipse. I have a jpl.jar and i have tried to import the jar file in eclipse with build path but i have this error: "no jpl in java.library.path". So i have copied libjpl.dylib in a /opt/local/lib/swipl-7.1.29/bin/ and when i execute the code i have this error: "Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/local/lib/swipl-7.1.29/bin/libjpl.dylib: dlopen(/opt/local/lib/swipl-7.1.29/bin/libjpl.dylib, 1): Library not loaded: /Users/janw/stable/lib/swipl/lib/x86_64-darwin13.0.0/libswipl.dylib Referenced from: /opt/local/lib/swipl-7.1.29/bin/libjpl.dylib Reason: image not found"

1

1 Answers

2
votes

After a anoying waste of time i found the solution about that problem. First of all, its completely necesary to install swi-prolog via macports, if not, as i did, when you point in the

Djava.library.path=/users/rivax/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin13.0.0

this exception will apear

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/rivax/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin13.0.0/libjpl.dylib: dlopen(/Users/rivax/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin13.0.0/libjpl.dylib, 1): Library not loaded: /Users/janw/stable/lib/swipl/lib/x86_64-darwin13.0.0/libswipl.dylib Referenced from: /Users/rivax/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin13.0.0/libjpl.dylib Reason: image not found at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1880) at java.lang.Runtime.loadLibrary0(Runtime.java:849) at java.lang.System.loadLibrary(System.java:1088) 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 consultasProlog.Consultas.consultaFicheroProlog(Consultas.java:19) at utilidades.RellenarModelo.ejecutarArchivo(RellenarModelo.java:30) at javaprolog.JavaProlog.main(JavaProlog.java:30) Java Result: 1

So follow these steps.

  1. port install swi-prolog on terminal , if you dont have install already macports command not found will apear so go to https://www.macports.org/install.php and install macports.
  2. navigate to the path of swi prolog macports installation which mine is /opt/local/lib/swipl-6.6.6/lib/x86_64-darwin14.0.0
  3. copy this path and set in java.library.path in the java VM as -Djava.library.path=/opt/local/lib/swipl-6.6.6/lib/x86_64-darwin14.0.0

Now .pl with jpl.jar will be able to execute and the consults will run.

Hope it will help you and every person who find this hell problem.

Cheers frank.