# Xpce on mac

**URL:** <https://swi-prolog.discourse.group/t/xpce-on-mac/3642>\
**Category:** Installing\
**Tags:** macos\
**Created:** [February 23, 2021, 1:06am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642 "2021-02-23T01:06:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/chipnowacek/32/3328_2.png) [@ChipNowacek](https://swi-prolog.discourse.group/u/ChipNowacek)\
**Post date:** [February 23, 2021, 1:06am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/1 "2021-02-23T01:06:34Z")

</div>

Cannot get xpce into the build on macOS for love or money. Please forgive my barfing up all the details below. Any guidance would be appreciated.

```
% brew list
aom fribidi jpeg libtasn1 opencore-amr snappy
apr gcc krb5 libtiff openjdk@11 speex
apr-util gd lame libtool openjpeg sqlite
argon2 gdbm leptonica libunistring openldap srt
aspell gettext libarchive libvidstab openssl@1.1	
autoconf ghostscript libass libvorbis opus tcl-tk
bdw-gc giflib libb2 libvpx ossp-uuid tesseract
berkeley-db git libbluray libx11 p11-kit texinfo
brotli glib libev libxau pcre theora
c-ares gmp libevent libxcb pcre2 tidy-html5
cairo gnu-sed libffi libxdmcp php unbound
cmake gnutls libidn2 libxpm pixman unixodbc
curl gobject-introspection	libmetalink libyaml pkg-config w3m
cvs grakn-core libmpc libzip postgresql webp
datomic graphite2 libogg little-cms2 postgresql@11 wget
dav1d guile libpng lz4 python@3.8 x264
emacs harfbuzz libpq lzo python@3.9 x265
ffmpeg httpd libpthread-stubs	mpfr q xorgproto
flac icu4c libsamplerate neo4j rav1e xvid
fontconfig iftop libsndfile nettle readline xz
freetds isl libsodium nghttp2 rtmpdump zeromq
freetype jansson libsoxr ninja rubberband zimg
frei0r jemalloc libssh2 oniguruma sdl2 zstd
emacs grakn-workbase inkscape java mactex xquartz

```

And the install:

```
% brew install --build-from-source swi-prolog --HEAD

==> **Cloning https://github.com/SWI-Prolog/swipl-devel.git**

Updating /Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git

==> **Checking out branch master**

Already on 'master'

Your branch is up to date with 'origin/master'.

HEAD is now at 264c8fe DOC: csv_read_file_row/3: to be done note was outdated. Boris Vassilev.

Entering 'bench'

Entering 'debian'

Entering 'packages/PDT'

Entering 'packages/RDF'

Entering 'packages/archive'

Entering 'packages/bdb'

Entering 'packages/chr'

Entering 'packages/clib'

Entering 'packages/clpqr'

Entering 'packages/cpp'

Entering 'packages/cppproxy'

Entering 'packages/cql'

Entering 'packages/http'

Entering 'packages/inclpr'

Entering 'packages/jpl'

Entering 'packages/libedit'

Entering 'packages/ltx2htm'

Entering 'packages/nlp'

Entering 'packages/odbc'

Entering 'packages/paxos'

Entering 'packages/pcre'

Entering 'packages/pengines'

Entering 'packages/pldoc'

Entering 'packages/plunit'

Entering 'packages/protobufs'

Entering 'packages/readline'

Entering 'packages/redis'

Entering 'packages/semweb'

Entering 'packages/sgml'

Entering 'packages/ssl'

Entering 'packages/swipl-win'

Entering 'packages/table'

Entering 'packages/tipc'

Entering 'packages/utf8proc'

Entering 'packages/windows'

Entering 'packages/xpce'

Entering 'packages/yaml'

Entering 'packages/zlib'

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/bench

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/debian

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/PDT

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/RDF

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/archive

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/bdb

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/chr

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/clib

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/clpqr

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/cpp

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/cppproxy

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/cql

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/http

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/inclpr

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/jpl

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/libedit

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/ltx2htm

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/nlp

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/odbc

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/paxos

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/pcre

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/pengines

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/pldoc

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/plunit

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/protobufs

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/readline

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/redis

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/semweb

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/sgml

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/ssl

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/swipl-win

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/table

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/tipc

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/utf8proc

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/windows

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/xpce

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/yaml

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/zlib

==> **cmake .. -DSWIPL_PACKAGES_JAVA=OFF -DSWIPL_PACKAGES_X=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/swi-prolog/HEAD-264c8fe/libexec**

==> **make install**

🍺 /usr/local/Cellar/swi-prolog/HEAD-264c8fe: 946 files, 22MB, built in 2 minutes 39 seconds
```

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 23, 2021, 7:34am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/2 "2021-02-23T07:34:22Z")

</div>

> [@ChipNowacek](#):
>
> `-DSWIPL_PACKAGES_X=OFF`

This disables building xpce …

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/chipnowacek/32/3328_2.png) [@ChipNowacek](https://swi-prolog.discourse.group/u/ChipNowacek)\
**Post date:** [February 23, 2021, 11:46pm UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/3 "2021-02-23T23:46:53Z")

</div>

Indeed it does. I’m not sure how it is getting set. As best I can tell, I have all prerequisites installed. I was assuming a configure step wasn’t happy and set `-DSWIPL_PACKAGES_X=OFF` because it didn’t see something it wanted to see.

Thanks for your reply — and for creating such an important system.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 24, 2021, 7:49am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/4 "2021-02-24T07:49:07Z")

</div>

Someone should probably try to get the Homebrew formulas updated. I once tried, but getting X11 dependency into a formula accepted seems hard. Building a good working SWI-Prolog is a bit hard on the Mac these days. The Xcode clang compiler creates a working, but rather slow system after serious performance regression with Xcode 11. Compiled using a modern GCC version and PGO guided optimization results in a system that is over twice as fast.

If anyone wants to give it a try to create good formulas and get them accepted with the Homebrew project, please do. I’m happy to help.

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/chipnowacek/32/3328_2.png) [@ChipNowacek](https://swi-prolog.discourse.group/u/ChipNowacek)\
**Post date:** [February 24, 2021, 1:09pm UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/5 "2021-02-24T13:09:06Z")

</div>

Thanks for taking the time to explain. It helps knowing why things are goofy.

I’ve never built a Homebrew formula, never mind navigated the Xcode jungle. If _you_ consider it hard, it’s probably a moon shot for me. That said, I’ll try.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 24, 2021, 1:29pm UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/6 "2021-02-24T13:29:52Z")

</div>

It was mostly (too) hard to get the formula accepted with the Homebrew team. They have zillions of guidelines and policies that must be respected. That is fair enough and necessary to avoid a project getting a big mess. Typically if a patch is “close enough” I fix the details and indicate what I changed why. That is IMO a lot more productive than pointing at yet another policy, in particular for one-time contributors.

I had a similar encounter with Macports, but one of the maintainers there kindly made it completely in accordance with their guidelines and I wrote a script to update the Portfile automatically. The Macport releases are smooth now. It should only be possible to select gcc and PGO driven opmization ☹

If you want to give it a try, tell me and I’ll see whether I can still find the work I did.

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/chipnowacek/32/3328_2.png) [@ChipNowacek](https://swi-prolog.discourse.group/u/ChipNowacek)\
**Post date:** [February 24, 2021, 1:51pm UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/7 "2021-02-24T13:51:35Z")

</div>

Thanks again. Navigating Homebrew’s guidelines under current circumstances is out of my wheelhouse. Thanks for your Macports work. I’ll head over there.

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/chipnowacek/32/3328_2.png) [@ChipNowacek](https://swi-prolog.discourse.group/u/ChipNowacek)\
**Post date:** [February 27, 2021, 7:59pm UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/8 "2021-02-27T19:59:19Z")

</div>

After doing some poking, it’s not at all clear Macports and Homebrew play well together. Is Docker a solid option on Mac?

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/chipnowacek/32/3328_2.png) [@ChipNowacek](https://swi-prolog.discourse.group/u/ChipNowacek)\
**Post date:** [February 27, 2021, 10:51pm UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/9 "2021-02-27T22:51:20Z")

</div>

I guess I’m out of luck for X on Docker too. I guess that makes sense.

```
?- check_installation.

% Checking your SWI-Prolog kit for common issues ...

%

% Version: ............. 8.3.18

% Address bits: ........ 64

% Architecture: ........ x86_64-linux

% Installed at: ........ /usr/lib/swipl

% Cores: ............... 4

%

% Checking tcmalloc ............................ ok

% Checking gmp ................................. ok

% Loading library(archive) ..................... ok

% Supported filters: bzip2, compress, gzip, grzip, lrzip, lzip, lzma, lzop, none, rpm, uu, xz

% Supported formats: 7zip, ar, cab, cpio, empty, gnutar, iso9660, lha, mtree, rar, raw, tar, xar, zip

% Loading library(cgi) ......................... ok

% Loading library(crypt) ....................... ok

% Loading library(bdb) ......................... ok

% Loading library(double_metaphone) ............ ok

% Loading library(filesex) ..................... ok

% Loading library(http/http_stream) ............ ok

% Loading library(http/json) ................... ok

% Loading library(http/jquery) ................. ok

% jQuery from /usr/lib/swipl/library/http/web/js/jquery-1.11.3.min.js

% Loading library(isub) ........................ ok

Warning: library(jpl) .......................... NOT FOUND

Warning: See http://www.swi-prolog.org/build/issues/jpl.html

% Loading library(memfile) ..................... ok

% Loading library(odbc) ........................ ok

Warning: library(pce) .......................... NOT FOUND

Warning: See http://www.swi-prolog.org/build/issues/xpce.html

% Loading library(pcre) ........................ ok

% Loading library(pdt_console) ................. ok

% Loading library(porter_stem) ................. ok

% Loading library(process) ..................... ok

% Loading library(protobufs) ................... ok

% Loading library(editline) .................... ok

% Loading library(readline) .................... ok

% Loading library(readutil) .................... ok

% Loading library(rlimit) ...................... ok

% Loading library(semweb/rdf_db) ............... ok

% Loading library(semweb/rdf_ntriples) ......... ok

% Loading library(semweb/turtle) ............... ok

% Loading library(sgml) ........................ ok

% Loading library(sha) ......................... ok

% Loading library(snowball) .................... ok

% Loading library(socket) ...................... ok

% Loading library(ssl) ......................... ok

% Loading library(crypto) ...................... ok

% Loading library(syslog) ...................... ok

% Loading library(table) ....................... ok

% Loading library(time) ........................ ok

% Loading library(tipc/tipc) ................... ok

% Loading library(unicode) ..................... ok

% Loading library(uri) ......................... ok

% Loading library(uuid) ........................ ok

% Loading library(zlib) ........................ ok

% Loading library(yaml) ........................ ok

Warning: Found 2 issues.

**true.**

?-
```

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/chipnowacek/32/3328_2.png) [@ChipNowacek](https://swi-prolog.discourse.group/u/ChipNowacek)\
**Post date:** [February 28, 2021, 1:01am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/10 "2021-02-28T01:01:03Z")

</div>

Going to try Debian in VMWare

---

<div class="post-metadata">

**Author:** ![Boris](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/boris/32/7486_2.png) [@Boris](https://swi-prolog.discourse.group/u/Boris)\
**Post date:** [February 28, 2021, 7:02am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/11 "2021-02-28T07:02:26Z")

</div>

I tried to see how the whole thing works on my Mac, and it turns out it doesn’t work too well.

First, what works:

I am able to compile from source after installing all dependencies, including gcc, using homebrew. I am able to tell cmake to do what I mean, like this, from inside the `build` directory (see [SWI-Prolog -- Installation on Linux, \*BSD (Unix)](https://www.swi-prolog.org/build/unix.html)):

```prolog
cmake -DCMAKE_C_COMPILER=/usr/bin/gcc \
      -DCMAKE_CXX_COMPILER=/usr/bin/g++ \
      -DCMAKE_INSTALL_PREFIX="$HOME"/bin/swipl \
      -DSWIPL_PACKAGES_JAVA=OFF \
      -DCMAKE_BUILD_TYPE=Release \
      -G Ninja ..

```

However, _now_, when I start the graphical editor or debugger, I am getting never seen before warnings and the text is somehow very wide (every character is followed by about two white spaces?).

```prolog
?- edit(aggregate_all/3).
true.

?- XPCE Xt warning: locale not supported by Xlib, locale set to C
Fontconfig warning: ignoring UTF-8: not a valid region tag

```

Some googling tells me that _many_ projects suffer from similar issues. I can’t be now bothered to figure out how to fix it ☹

This is annoying because I had managed to get it to work after some effort, but now it is broken. I suspect the MacOS upgrades.

Altogether the development experience on a (pretty modern) Mac has been crap. Every time the OS **forcefully** upgrades itself (every other week), a lot of stuff is broken (like, git doesn’t work) and I need to do this one trick:

```prolog
xcode-select --install

```

I won’t complain more, but depending on what you are doing, it might indeed be easier to just do your development on a developer-friendly OS 🙂

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 28, 2021, 8:25am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/12 "2021-02-28T08:25:11Z")

</div>

Some remarks.

- Using `/usr/bin/gcc` doesn’t work. These are links to the Xcode clang compiler. If you install gcc using Macports, gcc is named `gcc-mp-10` (depending on the version). You find the way the various binary releases are build in `scripts/make-distribution`.
- Typically it should be enough to install using the binary bundle from the download page. That version is fully optimized and provides X11 if you install XQuartz. Unfortunately the thing is really brittle recently. Indeed, most MacOS and XQuartz upgrades break the thing over and over again. Sometimes it works to deinstall and reinstall XQuartz. Sometimes it doesn’t. That is, for the App. The commandline version is included in the app and can (normal installation) be found at the location below. That version runs fine

```prolog
/Applications/SWI-Prolog.app/Contents/MacOS/swipl

```

- MacOS locale handling and POSIX applications do not play well. I think most is fixed if you set the `LANG` environment in your shell’s profile file. I use `export LANG=en_GB.UTF-8`.

All in all you can develop on a Mac but it is all way more brittle than on a Linux machine.

---

<div class="post-metadata">

**Author:** ![kuniaki.mukai](https://avatars.discourse-cdn.com/v4/letter/k/c67d28/32.png) [@kuniaki.mukai](https://swi-prolog.discourse.group/u/kuniaki.mukai)\
**Post date:** [February 28, 2021, 8:25am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/13 "2021-02-28T08:25:49Z")

</div>

I run everyday the following shell script to update SWIPL git, without enough knowledge to explain meaning of the script. So far, fortunately, it works for me on macOS Big Sur, emacs, ediprolog mode.

```prolog
#! /bin/sh
echo " updating swipl ..."
pushd ~/src/swipl-devel/build
git pull

# only for prepare.
# git submodule update --init

echo "Continue ? (Y/n/r(emove cache, then ninja ...))"
stty raw -echo
char=`dd bs=1 count=1 2>/dev/null`
stty -raw echo

if [$char == y]
then
	 echo "Compiling SWI-Prolog."
     continue
elif [$char == r]
then
	echo " Removing cmake cache, and Compiling. "
	rm -f "${HOME}/${USER}/src/swipl-devel/build/CMakeCache.txt"
	cmake -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_INSTALL_PREFIX=$HOME -G Ninja ..
	continue
else
	 echo "No updates."
     exit 0
fi

# only on first time
# cmake -DCMAKE_INSTALL_PREFIX=$HOME -G Ninja ..
ninja

# BUILDSWIPL=${HOME}/src/swipl-devel/build/src/swipl
# codesign -s "My Signing Identity" -f ${BUILDSWIPL}
# echo "\nninja codesign done\n"
# ctest -j 8
ninja install

echo "\nDone: swipl built.\n"
# codesign -s "My Signing Identity" -f ${SWIPL}
# echo "\ncodesign done\n"

# dump-pacs
popd;
exit 0

```

---

<div class="post-metadata">

**Author:** ![Boris](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/boris/32/7486_2.png) [@Boris](https://swi-prolog.discourse.group/u/Boris)\
**Post date:** [February 28, 2021, 11:46am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/14 "2021-02-28T11:46:34Z")

</div>

> [@jan](#):
>
> Using `/usr/bin/gcc` doesn’t work. These are links to the Xcode clang compiler.

You are correct and this is almost evil 🙂

```plaintext
% gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

```

I guess it is `gcc-10` when installed with homebrew:

```plaintext
% gcc-10 --version   
gcc-10 (Homebrew GCC 10.2.0_4) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

```

---

<div class="post-metadata">

**Author:** ![ChipNowacek](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/chipnowacek/32/3328_2.png) [@ChipNowacek](https://swi-prolog.discourse.group/u/ChipNowacek)\
**Post date:** [March 1, 2021, 1:59am UTC](https://swi-prolog.discourse.group/t/xpce-on-mac/3642/15 "2021-03-01T01:59:36Z")

</div>

Well, thanks for poking around for me and everyone else. My `check_installation.` looks good running a snap install on Debian running in VMWare Fusion.

> might indeed be easier to just do your development on a developer-friendly OS

Amen.

Again, thanks.
