I'm looking for a light-weight Prolog engine to be embedded in an Obj-C application under Mac OSX.
In Java there are some excellent implementations with the characteristics I need: deployability, lightness, dynamic configurability, integration with Java and ease of interoperability.
Can you recommend something similar in C/C++?
After several searches I found YAProlog and reading here it seems it can be used as library to be called from other programs. But (stupid questions):
GProlog
supports Mac OS X (Darwin) and there's an installer for Mac OS X Leopard. And here you can read how to call gprolog from C (read also this). Then instead of using gplc
, you can use gcc
provided that you add the proper options for linking, which could be a bit "trickie" to be found; so you can produce object files with gplc
and then glue everything together...
About YAP:
1) Usually package with autoconf are compiled simply with the following "sequence" of commands
./configure
make
A final make install
should install everything and must be executed by a user having the rights to do so. The manual suggest the creation of an ARCH
(ARCH.?) dir and doing everything from there (so, ../configure
instead of ./configure
).
The configure
script accepts usually options, take a look at them. Check in particular where are LIBDIR
and YAPLIBDIR
.
So, once you have the source tarball (the .tar.gz
of the source), you should dearchive it, a command like tar -xzf Yap-5.1.3.tar.gz
works on GNU/Linux and the same tar
should be also on Mac OS X...
Let's look at ./configure --help
and look if you see interesting option you want to use before proceeding.
Now, let's follow manual's suggestion (even if it looks odd to me;-))
mkdir ARCH. # I would put GNUlinux, or maybe
# the name must be exactly this?
cd ARCH.
../configure
You wait... and the directory gets populated of evrything needed for the next step. Take a look at the created Makefile
, you see lines like
#
# where YAP should look for binary libraries
#
LIBDIR=$(EROOTDIR)/lib
YAPLIBDIR=$(EROOTDIR)/lib/Yap
Among the targets of the Makefile, I can read also libYap.a
. So, try the make
(I won't do that to check what can go wrong, also because I am on GNU/Linux and how I can solve problems could be different), at the end, you should obtain the libYap.a
, and so, become "root" (administrator) and do
make install
In the install
target (exactly install_unix
for me) I read $(INSTALL_DATA) -m 755 libYap.a $(DESTDIR)$(LIBDIR)
which means that your .a
is installed and should be ready to be used by a compiler, provided you know where the lib is (and you know it, see above and remember the configure's options)
2) Of course you can copy it directly where you need it and use it "directly", but since it is "canonically" installed by the make install
, use it the way you'd use any other "system wide" lib archive.