Did you know ... Search Documentation:
SWI-Prolog owl logoBuilding SWI-Prolog on MacOS (Lion and Snow Lion)

Last updated: June 17, 2013, homebrew

Using Macports

Building SWI-Prolog for MacOS requires Macports. In general, the Portfiles are kept nicely up-to-date thanks to Paulo Moura. If you are a Macport user, SWI-Prolog can be installed simply using one of the commands below. The first installs the `stable' version and the second the `development' version. Note that most of the time developers are better of using the development version.

port install swi-prolog
port install swi-prolog-devel

If you like to keep nice and lean system (i.e., if you do not want Macports copies of X11, ODBC, etc), you still need to install several prerequisites. First:

  1. Xcode (can be installed as a free app from the appstore)
  2. Macports (download from http://www.macports.org/)
  3. X11. This is an OS option for Lion (10.7) and must be installed from http://xquartz.macosforge.org/landing/ for Mountain Lion (10.8).

Next, you must install the following Macport libraries:

port install gmp jpeg libarchive libiconv libmcrypt ncurses \
             openssl ossp-uuid pkgconfig readline zlib pcre libedit

Next, you can download SWI-Prolog as a source archive or using GIT. If you downloaded using GIT you must prepare the sources. If you downloaded the source archive theses steps are not needed (and in fact fail). Preparing the GIT source requires GNU autoconf from Macpors:

port install autoconf

Next, prepare by running the prepare script. Omit the --yes if you want a non-default installation.

./prepare --yes

From here, the source archive and GIT alternatives are united. You can build SWI-Prolog and all packages using the build script as follows:

cp build.templ build
<edit build, following comments>
./build

Using Homebrew

Homebrew provides an alternative to Macports. The command below installs the latest stable version of SWI-Prolog:

brew install swi-prolog

The latest git version of SWI-Prolog can be installed with this command:

brew install swi-prolog --HEAD

(contributed by Rinke Hoekstra)

See also
- The Portfile
- The scripts for building a binary release as distributed through our download pages are available in a git repository. Use
git clone git://www.swi-prolog.org/home/pl/git/misc/macos-build.git