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):
- I’m inexperienced with UNIX and I don’t know exactly how to produce libyap.a file with those commands of the YAP manual…
- Can I then copy libyap.a in my Xcode project and use it?
GPrologsupports 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 usinggplc, you can usegccprovided that you add the proper options for linking, which could be a bit “trickie” to be found; so you can produce object files withgplcand then glue everything together…About YAP:
1) Usually package with autoconf are compiled simply with the following “sequence” of commands
A final
make installshould install everything and must be executed by a user having the rights to do so. The manual suggest the creation of anARCH(ARCH.?) dir and doing everything from there (so,../configureinstead of./configure).The
configurescript accepts usually options, take a look at them. Check in particular where areLIBDIRandYAPLIBDIR.So, once you have the source tarball (the
.tar.gzof the source), you should dearchive it, a command liketar -xzf Yap-5.1.3.tar.gzworks on GNU/Linux and the sametarshould be also on Mac OS X…Let’s look at
./configure --helpand 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;-))
You wait… and the directory gets populated of evrything needed for the next step. Take a look at the created
Makefile, you see lines likeAmong the targets of the Makefile, I can read also
libYap.a. So, try themake(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 thelibYap.a, and so, become “root” (administrator) and doIn the
installtarget (exactlyinstall_unixfor me) I read$(INSTALL_DATA) -m 755 libYap.a $(DESTDIR)$(LIBDIR)which means that your.ais 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.