-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallation_guide.html
More file actions
491 lines (331 loc) · 20.3 KB
/
installation_guide.html
File metadata and controls
491 lines (331 loc) · 20.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>JPC Installation Guide</title>
<link rel="stylesheet" href="/styles/publication/sc.tutorial.css" />
<link rel="stylesheet" href="/styles/publication/sc.tooglejs.css" />
<script type="text/javascript" src="/js/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/ace-builds/src-noconflict/ace.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/publication/jquery.tableofcontents.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/publication/jquery.sc.publication.js" charset="utf-8"></script>
<script type="text/javascript">//<![CDATA[
(function ($) {
$(document).ready(function(){
$('#table_of_content_entries').tableOfContents('#content', {startLevel:2, depth: 3});
$.prettifyCodeSnippets("eclipse");
//$.prettifyCodeSnippets("solarized_light");
$.configureFootnotes();
})
})(jQuery);
//]]></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-47515052-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<h1>JPC Installation Guide</h1>
<div id="table_of_content">
<strong>Contents</strong>
<ol id="table_of_content_entries"></ol>
</div>
<div id="content">
<h2>Introduction</h2>
<p>
This guide overviews how to install JPC, its drivers, compatible Prolog engines and examples.
</p>
<p>
Although this document covers the installation of all the distinct artefacts that may be required in an application using JPC,
typically only a small subset of them are needed (e.g., only one Prolog engine and one JPC driver).
</p>
<h2>Requirements</h2>
To develop with JPC you require:
<div class="divList">
<ul>
<li><a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" title="Java Download">Java</a> 8 or above.</li>
<li>A <a href="architecture.html#compatiblePrologEngines" title="Compatible Prolog engine">compatible Prolog engine</a>.</li>
<li><a href="http://logtalk.org/" title="Logtalk: An open source object-oriented logic programming language">Logtalk</a> (optional for Java to Prolog, required for Prolog to Java).</li>
</ul>
</div>
<p>
JPC has been tested in:
</p>
<div class="divList">
<ul>
<li>Mac OS X: 10.8.5 (Mountain Lion) and 10.9.2 (Mavericks)</li>
<li>Linux: Ubuntu 12.0.4 and 13.0.4</li>
</ul>
</div>
<p>
At the moment, no tests have been accomplished under Windows, although it should also work there without major issues.
</p>
<h2>Before Starting</h2>
<p>
JPC currently uses <a href="http://maven.apache.org/" title="Apache Maven">Maven</a> as its project management tool.
Therefore, the easiest way to include JPC in a project, its drivers, other dependency libraries and examples is by means of Maven.
Maven <a href="http://maven.apache.org/download.cgi" title="Apache Maven Download">download and installation instructions</a> are provided in its website.
</p>
<p>
Although JPC is still in alpha version, it is already available in the <a href="http://search.maven.org/#search%7Cga%7C1%7Cjava-prolog-connectivity" title="Maven central repository">Maven Central repository</a>.
However, some JPC related components (experimental drivers or extensions) may only be available in the Maven Snapshots repository.
To access components in the Snapshots repository, you may need to add the following to your Maven configuration file <code>~/.m2/settings.xml</code>:
</p>
<div class="codeEditor"><pre data-editor="xml" data-show-gutter="true">
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles></pre></div>
<h2>Installing a Prolog Engine</h2>
<p>
This section gives pointers to the installation instructions of <a href="architecture.html#compatiblePrologEngines" title="Compatible Prolog engine">JPC compatible Prolog engines</a>.
There are many ways to install those engines.
In certain cases, the best installation procedure for JPC is not the most obvious installation.
Hence, this section often includes some example installation steps that ensure compatibility with our library.
</p>
<h3>Installing SWI Prolog</h3>
<p>
JPC is compatible with the latest <a href="http://www.swi-prolog.org/" title="SWI Prolog">SWI</a> stable release (version 6.x at the time of writing).
<a href="http://www.swi-prolog.org/Download.html" title="SWI Prolog installation instructions">Installation instructions</a> for multiple platforms are provided by the SWI website.
</p>
<h4>SWI Prolog in Mac OS X</h4>
<p>
The SWI version used to test JPC was installed using <a href="http://www.macports.org/" title="Mac Ports">Mac Ports</a>. SWI provides <a href="http://www.swi-prolog.org/build/macos.html" title="SWI Prolog in Mac OS X">detailed instructions</a> about how to accomplish a Mac Ports installation.
</p>
<h4>SWI Prolog in Linux</h4>
<p>
To generate the <a href="http://www.swi-prolog.org/packages/jpl/" title="JPL: A bidirectional Prolog/Java interface">required Java interoperability library</a>, SWI Prolog should be compiled from sources in Linux.
The SWI site provides information about the <a href="http://www.swi-prolog.org/build/LinuxDistro.txt" title="Required dependencies">required packages</a> needed before starting the installation and <a href="http://www.swi-prolog.org/git.html" title="SWI sources">how to download the sources</a>.
Afterwards, build and install both the SWI core and the tools according to the <a href="http://www.swi-prolog.org/build/unix.html" title="Building and installing SWI sources">provided instructions</a>.
Note that for a 32-bits OS you may need to <a href="http://www.codecompiling.net/node/137" title="Installing SWI in a 32-bits OS">run the configuration script with <code>--enable-shared</code></a>.
</p>
<h3>Installing YAP Prolog</h3>
<p>
JPC is compatible with the latest <a href="http://www.dcc.fc.up.pt/~vsc/Yap/" title="YAP Prolog">YAP</a> development version (version 6.3.3 at the time of writing).
<a href="http://www.dcc.fc.up.pt/~vsc/Yap/downloads.html" title="YAP Prolog installation instructions">Installation instructions</a> for multiple platforms are provided by the YAP website.
</p>
<h4>YAP Prolog in Mac OS X and Linux</h4>
<p>
Follow the instructions provided by the YAP website, taking care of adding the <code>--with-java</code> option when running the configuration script.
For example, the following command (executed in the <code>ARCH</code> folder as described in the YAP manual) compiles and install YAP generating the <a href="http://www.swi-prolog.org/packages/jpl/" title="JPL: A bidirectional Prolog/Java interface">required Java interoperability library</a>:
</p>
<div class="codeEditor"><pre data-editor="makefile" data-show-gutter="true">
../configure --prefix=/opt/local --with-java --enable-threads --enable-pthread-locking --enable-depth-limit --enable-coroutining --enable-clpbn-bp=no --enable-tabling --with-gmp=/opt/local && make && sudo make install</pre></div>
<p>
You may change these options as you wish, but remember to leave the <code>--with-java</code> option enabled.
Also, you may need to add <code>--enable-shared</code> for 32-bits OS.
</p>
<!--
After some test and fail trials from the author, this sequence of commands compile and install YAP sources with libraries required for JPC.
Download the latest development version with: <code>git clone git://git.code.sf.net/p/yap/yap-6.3</code>
Several packages are shared with SWI-Prolog and need to be obtained separately. Go to the download directory and proceed as follows: <code>git submodule init</code> and <code>git submodule update</code>
Create a folder <code>ARCH</code> and go to that folder.
Execute the following command: <code>CC=gcc-mp-4.4 CXX=g++-mp-4.4 ../configure --prefix=/opt/local --enable-threads --enable-pthread-locking --enable-depth-limit --enable-coroutining --with-java --enable-clpbn-bp=no --enable-tabling --with-gmp=/opt/local && make && sudo make install</code>
Note that this assumes that the gcc44 compiler is available.
-->
<h3>Installing XSB Prolog</h3>
<p>
JPC is compatible with the latest <a href="http://sourceforge.net/p/xsb/src/HEAD/tree/" title="XSB Prolog">XSB</a> development version. <!-- (version 3.4.0 at the time of writing)-->
<a href="http://xsb.sourceforge.net/downloads/downloads.html" title="XSB Prolog installation instructions">Installation instructions</a> for multiple platforms are provided by the XSB website.
</p>
<h4>XSB Prolog in Mac OS X and Linux</h4>
<p>
To compile and install XSB go to the <code>build</code> directory in the source tree and execute the following command:
</p>
<div class="codeEditor"><pre data-editor="makefile" data-show-gutter="true">
./configure -prefix=$SHARED_LIB && ./makexsb && sudo ./makexsb dynmodule && sudo ./makexsb install</pre></div>
<p>
Where <code>$SHARED_LIB</code> is the directory where you want to install XSB. For example: <code>/opt/local/lib/</code>.
Note that you may need <code>sudo</code> depending on the chosen installation location.
</p>
<h2>Installing Logtalk</h2>
<p>
Although JPC requires just a plain Prolog engine, many optional advanced features rely on <a href="http://logtalk.org/" title="Logtalk: An open source object-oriented logic programming language">Logtalk</a>.
Logtalk is an object-oriented logic programming language implemented using Prolog as a backend compiler.
The Logtalk website provides detailed <a href="http://logtalk.org/download.html" title="Logtalk installation instructions">installation instructions</a> together with many other resources.
</p>
<h2>Adding JPC to a Project</h2>
<p>
In order to include JPC into a project, add the following dependency to your <a href="https://maven.apache.org/pom.html#What_is_the_POM" title="What is the POM?">POM</a>:
</p>
<div class="codeEditor"><pre data-editor="xml" data-show-gutter="true">
<dependency>
<groupId>com.github.java-prolog-connectivity</groupId>
<artifactId>jpc</artifactId>
<version>0.0.1-alpha</version>
</dependency></pre></div>
<p>
Note that including the JPC library may be enough for development, but for executing your application you still need one or more JPC drivers.
</p>
<h2>Configuring JPC Drivers</h2>
<p>
All the current JPC drivers are open source<!-- and distributed under the terms of the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2 license</a>-->.
For convenience, both installation instructions for Maven users and <a href="http://stackoverflow.com/questions/11947037/what-is-an-uber-jar" title="Uber-Jars">Uber-Jars</a> containing each driver with its dependences are provided.
</p>
<h3 id="jplDriver">The JPL Based Driver</h3>
<h4 id="jplDriverArchitecture">Driver Architecture</h4>
<p>
The JPL based driver is implemented on top of the <a href="http://www.swi-prolog.org/packages/jpl/" title="JPL: A bidirectional Prolog/Java interface">JPL</a> library.
This driver is compatible with either SWI or YAP Prolog.
Since JPL is based on <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/jni/" title="JNI">JNI</a>, it is composed of both a Java part and a native C part.
You need to tell JPC (so it can tell in turn to JPL) where is located the C part.
Depending on the platform, the native part may be a library with a name similar to <code>libjpl.dylib (OSX)</code>, <code>libjpl.jnilib</code> (Linux) or <code>libjpl.dll</code> (Windows) in your SWI or YAP installation.
</p>
<h4 id="jplDriverMaven">Maven users</h4>
<p>
Add this dependency to your POM:
</p>
<div class="codeEditor"><pre data-editor="xml" data-show-gutter="true">
<dependency>
<groupId>com.github.java-prolog-connectivity</groupId>
<artifactId>jpc-jpl</artifactId>
<version>0.0.1-alpha</version>
</dependency></pre></div>
<h4 id="jplDriverDownload">Download the Driver Uber-Jar</h4>
<h4 id="jplDriverInstallation">Installation Instructions</h4>
<p>
To enable this driver follow these steps:
</p>
<div class="divList">
<ul>
<li>Configure the environment variable <code>JPLPATH_SWI</code> (in case you want to connect to SWI) with the SWI directory containing the native part of the JPL library.</li>
<li>Configure the environment variable <code>JPLPATH_YAP</code> (in case you want to connect to YAP) with the YAP directory containing the native part of the JPL library.</li>
</ul>
</div>
<p>
The OS specific instructions below are only relevant in Prolog to Java applications.
</p>
<h5>OSX Installation Instructions</h5>
<p>
Locate the directory where the JVM library <code> libjvm</code> is located and add it to the <code>DYLD_LIBRARY_PATH</code> environment variable.
The path should be similar to <code>$JAVA_HOME/Contents/Home/jre/lib</code>.
If you prefer to not modify such environment variable, alternatively you may use the <code>otool</code> utility. To do that, follow these steps:
</p>
<ul>
<li>Open a terminal and go to the directory where are located the dynamic SWI libraries. For example, if using the SWI-Prolog.app bundle, the path may be something similar to <code>/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin13.0.0</code>. You should see a file named <code>libjpl.dylib</code> in that directory.</li>
<li>Execute <code>otool libjpl.dylib -L</code> to see a list of the libraries currently linked with <code>libjpl.dylib</code>. You may see an entry similar to <code>/System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM</code>, pointing to the native OSX JVM.</li>
<li>Change this entry to point to the <code>libjvm.dylib</code> file in your preferred Java installation. To do this, type: <code>install_name_tool -change <OLD_ENTRY> <NEW_ENTRY> libjpl.dylib</code>. For example, you may execute something like: <code>install_name_tool -change /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM $JAVA_HOME/jre/lib/server/libjvm.dylib libjpl.dylib</code>.</li>
</ul>
<h5>Linux Installation Instructions</h5>
<p>
Locate the directory where the JVM library <code>libjvm</code> is located.
The path should be similar to <code>$JAVA_HOME/jre/lib/amd64/server</code> (assuming a 64 bits installation).
In several Linux distributions you will have to add that path to the <code>LD_LIBRARY_PATH</code> environment variable.
That is not correct for Ubuntu. For Ubuntu, you can create a <code>swipl.conf</code> file in the <code>/etc/ld.so.conf.d</code> directory.
In that file, write the path to the directory containing the JVM library.
Do not forget to execute <code>ldconfig</code> afterwards.
</p>
<!--
Note that configuring these environment variables is not necessary if Java is invoked with the parameter <code>java.library.path</code>, like:
<code>java -Djava.library.path="the_jpl_path"</code>.
Or, if the path to the Jpl native library is already part of the default search path of libraries in your operative system
(e.g., if it is included in <code>DYLD_LIBRARY_PATH</code> in OSX, or <code>LD_LIBRARY_PATH</code> in Linux).
-->
<h4 id="jplDriverFeatures">Driver Features</h4>
<p>
With this driver, only one Prolog session can be opened per JVM in Java to Prolog applications.
</p>
<!--
Please read the terms of the <a href="http://www.swi-prolog.org/packages/jpl/java_api/lgpl.html" title="JPL library license">JPL library license</a> before using this driver.
-->
<h3 id="interprologDriver">The InterProlog Based Driver</h3>
<h4 id="interPrologDriverArchitecture">Driver Architecture</h4>
<p>
The InterProlog based driver is implemented on top of the <a href="http://interprolog.com/java-bridge/" title="InterProlog: a Java front-end and enhancement for Prolog">InterProlog</a> library. This driver is compatible with XSB Prolog.
</p>
<h4 id="interPrologDriverInstallation">Installation Instructions</h4>
<div class="divList">
<p>
In order to include this driver in your project follow these steps:
</p>
<ul>
<li>Download and unzip the <a href="http://www.declarativa.com/interprolog/interprolog2.2a4.zip" title="InterProlog bundle">InterProlog bundle</a>.</li>
<li>Go to the directory where the <code>interprolog.jar</code> file is located and install it in your Maven local repository with this command:
<div class="codeEditor"><pre data-editor="makefile" data-show-gutter="true">
mvn install:install-file -Dfile=interprolog.jar -DgroupId=com.declarativa.interprolog -DartifactId=interprolog -Dversion=2.2a4 -Dpackaging=jar</pre></div>
</li>
<li>Add this dependency to your POM:
<div class="codeEditor"><pre data-editor="xml" data-show-gutter="true">
<dependency>
<groupId>com.github.java-prolog-connectivity</groupId>
<artifactId>jpc-interprolog</artifactId>
<version>0.0.1-alpha-SNAPSHOT</version>
</dependency></pre></div>
</li>
<li>Configure the environment variable <code>XSB_BIN_DIRECTORY</code> with the directory where the XSB binary is located.</li>
</ul>
</div>
<h4 id="interPrologDriverFeatures">Driver Features</h4>
<p>
This driver supports multiple Prolog sessions.
</p>
<!--
Please read the terms of the <a href="http://www.fsf.org/copyleft/lgpl.html" title="InterProlog library license">InterProlog library license</a> before using this driver.
-->
<h3 id="pdtDriver">The PDT Connector Based Driver</h3>
<h4 id="pdtDriverArchitecture">Driver Architecture</h4>
<p>
The PDT Connector based driver is implemented on top of the <a href="http://sewiki.iai.uni-bonn.de/research/pdt/connector/" title="Standalone PDT connector">PDT Connector</a> library. This driver is compatible with SWI Prolog.
</p>
<h4 id="pdtDriverInstallation">Installation Instructions</h4>
<p>
In order to include this driver in your project follow these steps:
</p>
<div class="divList">
<ul>
<li>Download the <a href="files/org.cs3.prolog.connector-2.1.0.jar" title="PDT connector jar">PDT connector jar</a>.</li>
<li>Go to the directory where the jar was downloaded and install it in your Maven local repository with this command:
<div class="codeEditor"><pre data-editor="makefile" data-show-gutter="true">
mvn install:install-file -Dfile=org.cs3.prolog.connector-2.1.0.jar -DgroupId=org.cs3.roots -DartifactId=org.cs3.prolog.connector -Dversion=2.1.0 -Dpackaging=jar</pre></div>
</li>
<li>Add this dependency to your POM:
<div class="codeEditor"><pre data-editor="xml" data-show-gutter="true">
<dependency>
<groupId>com.github.java-prolog-connectivity</groupId>
<artifactId>jpc-pdtconnector</artifactId>
<version>0.0.1-alpha-SNAPSHOT</version>
</dependency></pre></div>
</li>
<li>Configure the environment variable <code>SWI_BIN_DIRECTORY</code> with the directory where the SWI binary is located.</li>
</ul>
</div>
<p>
Note that configuring the last environment variable is optional in most cases.
If no provided, JPC will not pass any path to PDT (the underlying library of this driver) and the latter will attempt to find the SWI location.
</p>
<h4 id="pdtDriverFeatures">Driver Features</h4>
<p>
This driver supports multiple Prolog sessions.
</p>
<!--
Please read the terms of the <a href="https://sewiki.iai.uni-bonn.de/research/pdt/docs/v0.x/download" title="PDT Connector library license">PDT Connector library license</a> before using this driver.
-->
<h2 id="installingJpcExamples">Installing the JPC Examples</h2>
<p>
You can download some usage examples of JPC adding the following dependency to your POM:
</p>
<div class="codeEditor"><pre data-editor="xml" data-show-gutter="true">
<dependency>
<groupId>com.github.java-prolog-connectivity</groupId>
<artifactId>jpc-examples</artifactId>
<version>0.0.1-alpha</version>
</dependency></pre></div>
</div> <!-- end of content -->
</body>
</html>