pure-data/doc/1.manual/resources/chapter6.htm

<!DOCTYPE html>
<HTML lang="en">
<HEAD>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<TITLE>Pd Manual - Chapter 6: Building Pd from source</TITLE>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="pdmanual.css" media="screen">
<link rel="icon" href="favicon.ico">
</HEAD>
<BODY>

<div class="nav nav-top">
    <div class="nav-back"><A href="chapter5.htm">&lt; Chapter 5: Current status</A></div>
    <div class="nav-home"><A href="../index.htm#s6">Table of contents</A></div>
    <div class="nav-forward"></div>
</div>
<div id="corpus">

<IMG id="logo" src="icon.png" ALT="pd icon">

<H2>Chapter 6: Building Pd from source</H2>

<P>This chapter offers in depth details on how to build Pd from its source code
and install it on different operating systems (macOS, Linux, BSD & Windows).


<H3> <A href="#s6.1" id="s6.1"> 6.1. Requirements </A> </H3>

<P>Pd is built on the commandline using traditional Unix-style tools. The source
distribution comes with two build systems:</P>

<ul>
<li><b>autotools:</b> easy to use, many compilation options <b>(recommended for most users)</b></li>
<li><b>makefile:</b> smaller &amp; simpler, used for Pd binary downloads</li>
</ul>

<p>The core build requirements are:</p>

<ul>
<li>Unix command shell: bash, dash, etc</li>
<li>C compiler chain: gcc/clang &amp; make</li>
</ul>

<p>And a core runtime requirement is:</p>

<ul>
<li>Tcl/Tk: Tk wish shell</li>
</ul>

<p>Optional features:</p>

<ul>
<li>autotools: autoconf, automake, &amp; libtool (if building with the autotools)</li>
<li>gettext: build localizations in the po directory</li>
<li>JACK: audio server support</li>
<li>FFTW: use the optimized FFTW Fast Fourier Transform library</li>
</ul>


<H3> <A href="#s6.2" id="s6.2"> 6.2. General autotools build steps </A> </H3>

<p>Building Pd using the GNU autotools involves the following steps for all platforms:</p>

<ul>
<li>1. configure: detect &amp; set library and platform options</li>
<li>2. make: compile Pd, associated tools, and resource files (ie. translations)</li>
<li>3. install: install the Pd binaries and resources onto your system</li>
</ul>

<p>Overview:</p>

<pre>cd path/to/pd
./autogen.sh
./configure
make
</pre>

<p>Note: Additional platform-specific options and build targets are listed in following sections.</p>
<p>Start by opening a commandline shell and navigating to the Pd source directory:</p>

<pre>cd path/to/pd</pre>

<p>First generate the configure script and various build files by running:</p>

<pre>./autogen.sh</pre>

<p>Next configure Pd with the default options for your platform:</p>

<pre>./configure</pre>

<p>You can verify the configuration options that the configure step script prints:</p>

<pre>pd 0.55.0 is now configured

Platform:             Mac OSX
Debug build:          no
Universal build:      no
Localizations:        no
Source directory:     .
Installation prefix:  /usr/local

...

audio APIs:           PortAudio
midi APIs:            PortMidi</pre>

<p>If you want to change these options, you can specify/override the configure script settings on the commandline:</p>

<pre># change install prefix to /usr
./configure --prefix /usr

# build Pd with the JACK audio server backend
./configure --enable-jack

# build Pd using a system installed PortAudio
./configure --without-local-portaudio</pre>

<p>If you need to run Pd through a debugger (like gdb), you can
build Pd with debugging symbols using the "--enable-debug" flag.

<pre># build Pd with debugging information
./configure --enable-debug</pre>

<p>An important configure option for some platforms is --enable-universal which allows you to specify the desired architecture(s) when building Pd. For Intel and AMD processors, 32 bit is called &quot;i386&quot; and 64 bit is &quot;x86_64&quot;. By default, Pd is built for the architecture of the current system, however you may want a 32 bit Pd to work with existing 32 bit externals on a 64 bit system. You can override the defaults with --enable-universal:</p>

<pre># build 32 bit Pd
./configure --enable-universal=i386

# build 64 bit Pd
./configure --with-universal=x86_64</pre>

<p>You can compile a "Double precision" Pd (aka "Pd64") with:</p>

<pre>./configure --with-floatsize=64</pre>

<p>The full list of available configuration options can printed by running:</p>

<pre>./configure --help</pre>

<p>Now that Pd is configured, build by running:</p>

<pre>make</pre>

<p>Building should take a minute or two. If compilation was successful,
in Linux, you can run Pd from the build directory without installing it:</p>

<pre>cd bin
./pd</pre>

<p>You need to create an app so you can use your build in macOS and Windows.

<pre>make app</pre>

<p>To install to your Linux system using the configuration prefix
(default /usr/local), do:</p>

<pre>sudo make install</pre>

<p>You can also to a custom location via:</p>

<pre>make install DESTDIR=~/pd-xxx prefix=/</pre>

<p>Once installed, you should now be able to run Pd from the commandline:</p>

<pre>pd</pre>

<p>If want to uninstall, make sure Pd is configured and then run:</p>

<pre>sudo make uninstall</pre>

<p>If you compiled Pd using the --enable-universal configure
option and want to double check which architectures Pd was built
with, use the &quot;file&quot; command:</p>

<pre># examine binary in the src directory
file src/pd
...
src/pd: Mach-O 64-bit executable x86_64

# look at pd inside a macOS .app bundle
file Pd.app/Contents/Resources/bin/pd
...
Pd-0.55.0.app/Contents/Resources/bin/pd: Mach-O 64-bit executable x86_64</pre>

<p>More details specific to each platform follow next.

<H3> <A href="#s6.3" id="s6.3"> 6.3. Building Pd for Linux </A> </H3>

<p>Platform requirements:</p>

<ul>
<li>ALSA: Linux sound library (recommended)</li>
<li>OSS: historical precursor to ALSA, generally not used</li>
<li>JACK: JACK audio server (optional)</li>
</ul>

<p>Install the core build requirements using your distribution's package manager. For Debian, you can install the compiler chain, autotools, &amp; gettext with:</p>

<pre>sudo apt-get install build-essential automake autoconf libtool gettext</pre>

<p>For libraries, you will need to install the &quot;development&quot; versions which include the source code header files. In Debian, the ALSA development package is called &quot;libasound2-dev&quot;:</p>

<pre>sudo apt-get install libasound2-dev</pre>

<p>Similarly, optional development libraries can be also be installed to for additional features. Install the JACK development files on Debian:</p>

<pre>sudo apt-get install libjack-jackd2-dev</pre>

<p>In case you are using jackd1 instead of jackd2, use:</p>

<pre>sudo apt-get install libjack-dev</pre>

<p>Most distributions come with Tcl/Tk installed, so you should be able to run Pd after it is built.</p>
<p>Once your build system is set up, you can follow the general autotools build steps to build Pd.</p>


<H3> <A href="#s6.4" id="s6.4"> 6.4. Building Pd for BSD </A> </H3>

<p>Building Pd for the various BSD variants is similar to the Linux way.
The major difference is the used package manager (and the names of the packages),
you&rsquo;ll want to install.</p>

<H4> <A href="#s6.4.1" id="s6.4.1"> 6.4.1. FreeBSD </A> </H4>

<p>(Tested on FreeBSD-13)</p>

<p>Install the core build requirements:</p>

<pre><code>sudo pkg install gcc automake autoconf libtool gettext gmake
</code></pre>

<p>You may install one (or more) libraries (depending on your needs).
It seems that with FreeBSD-13, there are ALSA and JACK packages available:</p>

<pre><code>sudo pkg install alsa-lib jackit
</code></pre>

<p>Once your build system is set up, you can follow the general autotools build
steps to build Pd, but make sure to use <code>gmake</code> (aka &ldquo;GNU make&rdquo;).
The ordinary BSD <code>make</code> will not suffice!</p>

<pre><code>./autogen.sh
./configure --deken-os=FreeBSD MAKE=gmake
gmake

sudo gmake install
</code></pre>

<H4> <A href="#s6.4.2" id="s6.4.2"> 6.4.2. OpenBSD </A> </H4>

<p>(Tested on OpenBSD-7)</p>

<p>Install the core build requirements:</p>

<pre><code>sudo pkg_add gcc automake autoconf libtool gettext-tools gmake
</code></pre>

<p>(If there are multiple versions for one or more of the packages, pick your
favourite or the newest one).</p>

<p>You may install one (or more) libraries (depending on your needs).
It seems that with OpenBSD-7, there are only JACK packages available:</p>

<pre><code>sudo pkg_add jack
</code></pre>

<p>By default, OpenBSD installs all its packages into <code>/usr/local/</code>,
but the compiler does not look for headers resp. libraries in this directory.
We can instruct autotools to automatically consider these directories
by creating a file &lsquo;/usr/local/share/config.site&rsquo;:</p>

<pre><code>cat | sudo tee /usr/local/share/config.site&gt;/dev/null &lt;&lt; EOF
CPPFLAGS="-I/usr/local/include \$CPPFLAGS"
LDFLAGS="-L/usr/local/lib \$LDFLAGS"
EOF
</code></pre>

<p>Also, because OpenBSD allows to coinstall multiple versions of the autotools (with no &ldquo;default&rdquo;),
we must specify which version we want to use:</p>

<pre><code>export AUTOCONF_VERSION=$(ls -S /usr/local/bin/autoconf-* | sed -e 's|.*-||' | sort -n | tail -1)
export AUTOMAKE_VERSION=$(ls -S /usr/local/bin/automake-* | sed -e 's|.*-||' | sort -n | tail -1)
</code></pre>

<p>Now that your build system is set up, you can follow the general autotools build
steps to build Pd, but make sure to use <code>gmake</code> (aka &ldquo;GNU make&rdquo;).
The ordinary BSD <code>make</code> will not suffice!</p>

<pre><code>./autogen.sh
./configure --deken-os=OpenBSD --enable-jack MAKE=gmake
gmake

sudo gmake install
</code></pre>

<H4> <A href="#s6.4.3" id="s6.4.3"> 6.4.3. NetBSD </A> </H4>

<p>(Tested on NetBSD-9)</p>

<p>Install the core build requirements:</p>

<pre><code>sudo pkgin install gcc automake autoconf libtool gettext-tools gmake
</code></pre>

<p>You may install one (or more) libraries (depending on your needs).
It seems that with NetBSD-9, there are JACK and ALSA packages available,
but the ALSA packages seem to be broken. OSS appears to be built-in.</p>

<pre><code>sudo pkgin install jack</code></pre>

<p>By default, NetBSD installs all its packages into <code>/usr/pkg/</code>,
but the compiler does not look for headers resp. libraries in this directory.
We can instruct autotools to automatically consider these directories
by creating a file &lsquo;/usr/pkg/share/config.site&rsquo;:</p>

<pre><code>cat | sudo tee /usr/pkg/share/config.site&gt;/dev/null &lt;&lt; EOF
CPPFLAGS="-I/usr/pkg/include \$CPPFLAGS"
LDFLAGS="-L/usr/pkg/lib -Wl,-R/usr/pkg/lib \$LDFLAGS"
EOF </code></pre>

<p>Now that your build system is set up, you can follow the general autotools build
steps to build Pd, but make sure to use <code>gmake</code> (aka &ldquo;GNU make&rdquo;).
The ordinary BSD <code>make</code> will not suffice!</p>

<pre><code>./autogen.sh
./configure --deken-os=NetBSD --prefix=/usr/pkg --disable-alsa --enable-jack MAKE=gmake
gmake

sudo gmake install
</code></pre>


<H3> <A href="#s6.5" id="s6.5"> 6.5. Building Pd for macOS </A> </H3>

<p>macOS is built on top of a BSD system and the bash commandline
can be accessed with the Terminal application in the
/Applications/Utility directory.</p>

<p>The clang compiler and associated tools are provided by Apple.
If you are running macOS 10.9+, you <em>do not</em> need to install
the full Xcode application and can install the Commandline Tools
Package only by running the following:</p>

<pre>xcode-select --install</pre>

<p>For macOS versions earlier than 10.9, you will need to install
Xcode from the Mac App Store or downloaded
from <a href="http://developer.apple.com" target="_blank">http://developer.apple.com</a></p>

<p>Tcl/Tk is already included macOS.</p>

<p>To install the autotools, gettext, and libraries for additional
features, you can use one of the open source package managers for macOS:</p>

<ul>
<li>homebrew: <a href="https://brew.sh" target="_blank">https://brew.sh </a>(recommended)</li>
<li>macports: <a href="https://www.macports.org" target="_blank">https://www.macports.org</a></li>
</ul>

<p>Follow the package manager set up instructions and then install the
software you need. For example, to install the autotools &amp; gettext
using Homebrew:</p>

<pre>brew install automake autoconf libtool pkg-config gettext
brew link --force gettext</pre>

<p>By default, Pd is built for the current system architecture, usually 64 bit. If you want to override this you can use the --enable-universal configure option which allows you to specify the desired architecture(s) when building Pd. For Intel/AMD processors, 32 bit is called &quot;i386&quot; and 64 bit is &quot;x86_64&quot;. For Apple Silicon processors (M1, M2, etc), the 64 bit architecture is called &quot;arm64&quot;. By default, Pd is built for the architecture of the current system, however you may want a 32 bit Pd to work with existing 32 bit externals on a 64 bit system. You can override the defaults with --enable-universal: you want to override this you can use the --enable-universal configure option, as mentioned in the main Autotools Build section. On macOS, running this option without arguments will build a &quot;fat&quot; Pd for all architectures supported by the compiler:</p>

<ul>
<li>macOS 10.6: i386, x86_64, ppc</li>
<li>macOS 10.7+: i386, x86_64</li>
<li>macOS 10.15: x86_64</li>
<li>macOS 11+: x86_64, arm64</li>
</ul>

<p>Note: a &quot;fat&quot; Pd may not work on all systems and/or be
able to load both 32 or 64 bit externals. Additionally, you can specify
multiple architectures directly:</p>

<pre># build a &quot;fat&quot; Pd for both 32 and 64 bit Intel
# may not work on all systems
./configure --enable-universal=i386,x86_64

# build a &quot;fat&quot; Pd for all detected architectures (macOS: i386, x86_64, ppc)
# may not work on all systems
./configure --enable-universal</pre>

<p>The JACK audio server is supported by Pd on macOS. By default,
Pd can use either the official 64-bit builds for macOS 10.12+
from <a href="https://jackaudio.org" target="_blank">https://jackaudio.org</a>
or the older, 32-bit Jack OS X runtime framework if one is installed on the system.
Optionally, Pd can also be built with Jack installed via Homebrew or Macports,
however the runtime framework support must be disabled: </p>

<pre>brew install jack
./configure --disable-jack-framework --enable-jack</pre>

<p>You should now be ready to build Pd by following the general autotools
build steps. Once built, there are two options for installation:</p>

<ul>
<li>build a standalone macOS application (recommended)</li>
<li>install to your system as a commandline program</li>
</ul>

<p>To build the Pd macOS application, simply run:</p>

<pre>make app</pre>

<p>This builds Pd-#.##.#.app in the Pd source directory which can be then be double-clicked
and/or copied to /Applications. For more info &amp; options regarding the Pd .app bundle,
see <a href="chapter6.htm#s6.5.1"> 6.5.1. macOS app bundle</a>.

<p>If you want to have both the Pd application <em>and</em> use Pd from the commandline,
add command aliases to the binaries inside the .app to your ~/.bash_profile:</p>

<pre><code>WHICHPD=&quot;Pd-0.55-0&quot;
alias pd=&quot;/Applications/$WHICHPD.app/Contents/Resources/bin/pd&quot;
alias pdsend=&quot;/Applications/$WHICHPD.app/Contents/Resources/bin/pdsend&quot;
alias pdreceive=&quot;/Applications/$WHICHPD.app/Contents/Resources/bin/pdreceive&quot;
</code></pre>

<p>Next, reload the profile by either opening a new Terminal window or running:</p>

<pre>source ~/.bash_profile</pre>

<p>If you install Pd to your system with &quot;make install&quot;, the Tk 8.5.9 currently included with the system (as of macOS 10.14) is buggy and should <em>not</em> be used. It is recommended to install a newer version, either via Homebrew or from the ActiveState Tcl/Tk downloads.</p>

<p>To see which version the Pd GUI is using: set the log level to 4 &amp; look for the Tk version log line in the Pd window.</p>

<p>Another option is to set the Tk Wish command Pd uses to launch the GUI. At start, Pd does a quick search in the &quot;usual places&quot; for Wish and chooses the first path that exists. Versions of macOS up to 10.12 also ship with Tcl/Tk 8.4 which works fine and this wish can be invoked by Pd using the full path &quot;/usr/bin/wish8.4&quot;. You can configure Pd to use this search path first with:</p>

<pre>./configure --with-wish=/usr/bin/wish8.4</pre>

<p>To see Pd's path search info, run Pd with the -verbose flag:</p>

<pre>pd -verbose</pre>

<p>Note: Pd installed to your system or run from the build/bin directory will not use the default font and will be missing the various macOS GUI hints (such as retina rendering) which are specified by the Info.plist file inside the .app bundle. Again, it is recommended to build a .app and use the aforementioned aliases to provide the pd command.</p>

<H4> <A href="#s6.5.1" id="s6.5.1"> 6.5.1. macOS app bundle </A> </H4>

<p>Directory pure-data/mac contains support files for building a Pure Data macOS application
bundle and supplementary build scripts for compiling Pd on Macintosh systems, as it is built
for the &lsquo;vanilla&rsquo; releases on msp.ucsd.edu.</p>

<p>In a nutshell, a monolithic macOS &ldquo;application&rdquo; is simply a directory structure
treated as a single object by the OS. Inside this bundle are the compiled binaries, resource
files, and contextual information. You can look inside any application by either navigating
inside it from the commandline or by right-clicking on it in Finder and choosing &ldquo;Show
Package Contents.&rdquo;</p>

<p>The basic layout is:</p>

<pre><code>Pd-0.55-0.app/Contents
  Info.plist  &lt;- contextual info: version string, get info string, etc
  /Frameworks &lt;- embedded Tcl/Tk frameworks (optional)
  /MacOS/Pd   &lt;- renamed Wish bundle launcher
  /Resources
    /bin      &lt;- pd binaries
    /doc      &lt;- built in docs &amp; help files
    /extra    &lt;- core externals
    /font     &lt;- included fonts
    /po       &lt;- text translation files
    /src      &lt;- Pd source header files
    /tcl      &lt;- Pd GUI scripts
</code></pre>

<p>The Pure Data GUI utilizes the Tk windowing shell aka &ldquo;Wish&rdquo; at runtime.
Creating a Pure Data .app involves using a precompiled Wish.app as a wrapper
by copying the Pd binaries and resources inside of it.</p>

<H5> <A href="#s6.5.1.1" id="s6.5.1.1"> 6.5.1.1. macOS App bundle helpers </A> </H5>

<ul>
<li>osx-app.sh: creates a Pd .app bundle for macOS using a Tk Wish.app wrapper</li>
<li>tcltk-wish.sh: downloads and builds a Tcl/Tk Wish.app for macOS</li>
</ul>

<p>These scripts complement the autotools build system described in INSTALL.txt and
are meant to be run after Pd is configured and built. The following usage, for
example, downloads and builds a 32 bit Tk 8.6.6 Wish.app which is used to create
a macOS Pd-0.55-0.app:</p>

<pre><code>mac/tcltk-wish.sh --arch i386 8.6.6
mac/osx-app.sh --wish Wish-8.6.6.app 0.55-0
</code></pre>

<p>Both osx-app.sh &amp; tcltck-wish.sh have extensive help output using the &ndash;help
commandline option:</p>

<pre><code>mac/osx-app.sh --help
mac/tcltk-wish.sh --help
</code></pre>

<p>The osx-app.sh script automates building the Pd .app bundle and is used in the
&ldquo;make app&rdquo; makefile target. This default action can be invoked manually after
Pd is built:</p>

<pre><code>mac/osx-app.sh 0.55-0
</code></pre>

<p>This builds a &ldquo;Pd-0.55-0.app&rdquo; using the included Wish. If you omit the version
argument, a &ldquo;Pd.app&rdquo; is built. The version argument is only used as a suffix to
the file name and contextual version info is pulled from configure script
output.</p>

<p>A pre-built universal (32/64 bit) Tk 8.6.10+ Wish with patches applied is
included with the Pd source distribution and works across the majority of macOS
versions up to 10.15. This is the default Wish.app when using osx-app.sh. If you
want to use a different Wish.app (a newer version, a custom build, a system
version), you can specify the donor via commandline options, for example:</p>

<pre><code># build Pd-0.55-0.app using Tk 8.6 installed to the system
mac/osx-app.sh --system-tk 8.6 0.55-0
</code></pre>

<p>If you want Pd to use a newer version of Tcl/Tk, but do not want to install to
it to your system, you can build Tcl/Tk as embedded frameworks inside of the Pd
.app bundle. This has the advantage of portability to other systems.</p>

<p>The tcltk-wish.sh script automates building a Wish.app with embedded Tcl/Tk,
either from the release distributions or from a git clone:</p>

<pre><code># build Wish-8.6.6.app with embedded Tcl/Tk 8.6.6
mac/tcltk-wish.sh 8.6.6

# build Wish-master-git.app from the latest Tcl/Tk master branch from git
mac/tcltk-wish.sh --git master-git
</code></pre>

<p>You can also specify which architectures to build (32 bit, 64 bit, or both):</p>

<pre><code># build 32 bit Wish-8.6.6.app with embedded Tcl/Tk 8.6.6
mac/tcltk-wish.sh --arch i386 8.6.6

# build universal (32 &amp; 64 bit)
mac/tcltk-wish.sh --universal 8.6.6
</code></pre>

<p>Once your custom Wish.app is built, you can use it as the .app source for
osx-app.sh with the -w/&ndash;wish option:</p>

<pre><code># build Pd with a custom Tcl/Tk 8.6.6 Wish
mac/osx-app.sh -w Wish-8.6.6.app
</code></pre>

<p>Downloading and building Tcl/Tk takes some time. If you are doing lots of builds
of Pd and/or are experimenting with different versions of Tcl/Tk, building the
embedded Wish.apps you need with tcltk-wish.sh can save you some time as they
can be reused when (re)making the Pd .app bundle.</p>

<p>Usually, it&rsquo;s best to use stable releases of Tcl/Tk. However, there are times
when building from the current development version is useful. For instance,
if there is a bug in the Tcl/Tk sources and the generated Wish.app crashes on
your system, you can then see if there is a fix for this in the Tcl/Tk
development version on GitHub. If so, then you can test by using the
tcltk-wish.sh &ndash;git commandline option. Oftentimes, these kinds of issues will
appear with a newer version of macOS before they have been fixed by the open
source community.</p>

<p>Additionally, Pd uses an older version of Tcl/Tk for backwards compatibility on
macOS. As such, small bugfixes from newer versions may need to be backported for
the Pd GUI. Currently, this is handled in the tcltk-wish.sh script by applying
custom patches to either the Tcl and/or Tk source trees. To skip applying
patches, use the tcltk-wish.sh &ndash;no-patches commandline option. See
mac/patches/README.txt for more info.</p>

<H4> <A href="#s6.5.2" id="s6.5.2"> 6.5.2. Supplementary macOS build scripts </A> </H4>

<ul>
<li>build-macosx: builds a 32 bit Pd .app bundle using src/makefile.mac</li>
<li>build-mac64: builds a 64 bit Pd .app bundle using src/makefile.mac</li>
</ul>


<p>These scripts automate building Pd with the fallback makefiles in the src
directory.</p>

<p>To build a 32 bit Pd, copy this &ldquo;mac&rdquo; directory
somewhere like ~/mac. Also copy a source tarball there, such as
pd-0.55-0.src.tar.gz. Then cd to ~/mac and type:</p>

<pre><code>./build-macosx 0.55-0
</code></pre>

<p>If all goes well, you&rsquo;ll soon see a new app appear named Pd-0.55-0.app.</p>

<p>If you want to build a 64 bit Pd, perform the same steps and use the build-mac64
script:</p>

<pre><code>./build-mac64 0.55-0
</code></pre>

<p>Note: The &ldquo;wish-shell.tgz&rdquo; is an archive of this app I found on my mac:
/System/Library/Frameworks/Tk.framework/Versions/8.4/Resources/Wish Shell.app</p>

<p>A smarter version of the scripts ought to be able to find that file
automatically on your system so I wouldn&rsquo;t have to include it here.</p>

<H4> <A href="#s6.5.3" id="s6.5.3"> 6.5.3. Preferences </A> </H4>

<p>The Pure Data preferences are saved in the macOS &ldquo;defaults&rdquo; preference system
using the following domains:</p>

<ul>
<li>org.puredata.pd: core settings (audio devices, search paths, etc)</li>
<li>org.puredata.pd.pd-gui: GUI settings (recent files, last opened location, etc)</li>
</ul>

<p>The files themselves live in your user home folder and use the .plist extension:</p>

<pre><code>~/Library/Preferences/org.puredata.pd.plist
~/Library/Preferences/org.puredata.pd.pd-gui.plist
</code></pre>

<p>These files use the Apple Property List XML format and shouldn&rsquo;t be edited
directly. You can look inside, edit, and/or delete these using the &ldquo;defaults&rdquo;
commandline utility in Terminal:</p>

<pre><code># print the contents of the core settings
defaults read org.puredata.pd

# delete the current GUI settings
defaults delete org.puredata.pd.pd-gui

# set the startup flag in the core settings
defaults write org.puredata.pd -array-add flags '-lib Gem'
</code></pre>

<p>Some important per-application settings required by the GUI include:</p>

<ul>
<li>NSRecentDocuments: string array, list of recently opened files</li>
<li>NSQuitAlwaysKeepsWindows: false, disables default 10.7+ window state saving</li>
<li>ApplePressAndHoldEnabled: false, disables character compose popup,
                                 enables key repeat for all keys</li>
<li>NSRequiresAquaSystemAppearance: true, disables dark mode for Pd GUI on 10.14+</li>
</ul>

<p>These are set in:</p>
<pre><code>tcl/pd_guiprefs.tcl</code></pre>

<H4> <A href="#s6.5.4" id="s6.5.4"> 6.5.4. Code signing </A> </H4>

<p>As of Pd 0.51, the mac/osx-app.sh script performs &ldquo;ad-hoc code signing&rdquo; in order
to set entitlements to open un-validated dynamic libraries on macOS 10.15+. This
is required due to the new security settings. Note: ad-hoc signing doesn&rsquo;t
actually sign the .app bundle with an account certificate, so the unidentified
developer warning is still shown when the downloaded .app is run for the first
time.</p>

<H4> <A href="#s6.5.5" id="s6.5.5"> 6.5.5. Privacy permission </A> </H4>

<p>The macOS 10.14 release introduced system privacy permissions for actions
applications can undertake on a user account, such as accessing files or reading
microphone or camera input. When an application is started for the first time
and tries to access something that is covered by the privacy settings, a
permissions prompt is displayed by the system requesting access. The action is
then allowed or denied and this setting is saved and applied when the
application is run again in the future.</p>

<p>As of macOS 10.15, running Pd will request access for the following:</p>

<ul>
<li>Files and Folders: Documents</li>
<li>Files and Folders: Desktop</li>
<li>Microphone</li>
</ul>

<p>Additionally, using an external such as Gem for camera input will request
access to the Camera.</p>

<p>The current permissions can be changed in Privacy panel in System Preferences.
They can also be reset on the commandline using the &ldquo;tccutil&rdquo; command and the
Pd .app bundle id:</p>

<pre><code># reset Pd's Microphone privacy setting
tccutil reset Microphone org.puredata.pd.pd-gui

# reset all of Pd's privacy settings
tccutil reset All org.puredata.pd.pd-gui
</code></pre>

<H4> <A href="#s6.5.6" id="s6.5.6"> 6.5.6. Font issues with macOS 10.15+ </A> </H4>

<p>macOS 10.15 added further changes to font rendering beginning with 10.14, with
the weird result that Pd&rsquo;s default font, DejaVu Sans Mono, renders thinner and
with narrower letter spacing than system fonts. This results in objects on the patch
canvas being wider than their inner text and text selection positioning being off.</p>

<p>To remedy this for now, Pd 0.51-3 changed Pd&rsquo;s default font for macOS to Menlo
which is included with the system since 10.6. Menlo is based on Bitstream Vera
Mono and DejaVu Sans Mono, so there should be no issues with patch sizing or
positioning.</p>

<H4> <A href="#s6.5.7" id="s6.5.7"> 6.5.7. Dark mode </A> </H4>

<p>Pd currently disables Dark Mode support by setting the
NSRequiresAquaSystemAppearance key to true in both the app bundle&rsquo;s Info.plist
and the GUI defaults preference file. This restriction may be removed in the
future once Dark Mode is handled in the GUI.</p>

<H4> <A href="#s6.5.8" id="s6.5.8"> 6.5.8. Debugging releases </A> </H4>

<p>On macOS 10.15+, apps must be signed with an entitlement to allow debugging.
This is good for security, but bad if you want to run Pd in lldb to figure out
why your custom external is crashing.</p>

<p>To make this work, the entitlement can be added to an existing Pd release .app
bundle using the codesign command in Terminal (steps by Pierre Alexandre
Tremblay):</p>

<ul>
<li>Extract the current Pd entitlements from the internal pd binary:</li>
</ul>


<pre><code>    codesign -d /Applications/Pd-0.53-2.app/Contents/Resources/bin/pd \
    --entitlements :~/Desktop/pd-entitlements.xml
</code></pre>

<ul>
<li>Edit pd-entitlements.xml on your Desktop, add the following key, and save:</li>
</ul>


<pre><code>    &lt;key&gt;com.apple.security.get-task-allow&lt;/key&gt;
    &lt;true/&gt;
</code></pre>

<ul>
<li>Re-sign the pd binary with the updated entitlements:</li>
</ul>


<pre><code>    codesign -s - --deep --force --options=runtime \
    --entitlements ~/Desktop/pd-entitlements.xml \
    /Applications/Pd-0.53-2.app/Contents/Resources/bin/pd
</code></pre>

<p>Now Pd can be run with lldb using:</p>

<pre><code>lldb /Applications/Pd-0.53-2.app/Contents/Resources/bin/pd
</code></pre>

<p>Note: Re-signing using an ad-hoc identifier will work on the development system,
      but running the Pd .app bundle on another system will result in security
      warnings as the original signature and notarization are invalid.</p>


<H3> <A href="#s6.6" id="s6.6"> 6.6. Building Pd for Microsoft Windows </A> </H3>

<p>Pd on Windows can be built with either MinGW or Cygwin which provide the core build requirements: a compiler chain &amp; shell environment.</p>
<p>It is recommended to use the Msys2 distribution which provides both a Unix command shell and MinGW. Download the Msys2 &quot;x86_64&quot; 64 bit installer (or &quot;i686&quot; if you are using 32 bit Windows) from:</p>

<p><a href="http://www.msys2.org/" target="_blank">http://www.msys2.org/</a></p>

<p>Then install to the default location (C:32 or C:64) and follow the setup/update info on the Msys2 webpage.</p>
<p>Msys2 provides both 32 and 64 MinGW and command shells. As of Pd 0.50, the Pd release is 64 bit for Windows, so it is recommended to set up and use the MinGW 64 bit shell. If you want to build a 32 bit Pd, similarly use the MinGW 32 bit shell. Due to how MinGW is designed, you cannot build a 64 bit Pd with a 32 bit MinGW and vice versa. This also means the Pd configure --enable-universal build option has no effect in MinGW.</p>
<p>Note: Msys2 development seems to change frequently, so some of the package names below may have changed after this document was written.</p>
<p>Open an Msys2 shell and install the compiler chain, autotools, &amp; gettext via:</p>

<pre># 64 bit
pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang \
          make autoconf automake libtool \
          mingw-w64-x86_64-gettext

# 32 bit
pacman -S mingw-w64-i686-toolchain mingw-w64-i686-clang \
          make autoconf automake libtool \
          mingw-w64-i686-gettext</pre>

<p>Install git if you want to clone the Pd sources from Github, etc:</p>

<pre>pacman -S git</pre>

<p>and/or the nsis installer tool if you want to build the Pd Windows installer:</p>

<pre># 64 bit
pacman -S mingw-w64-x86_64-nsis

# 32 bit
pacman -S mingw-w64-i686-nsis</pre>

<p>Note: You can also search for packages in Msys2 with:</p>

<pre>pacman -S -s &lt;searchterm&gt;</pre>

<p>Once the packages are installed, you should now be ready to build Pd by following the general autotools build steps.</p>
<p>The following audio APIS are available on Windows and can be enabled/disabled via their configure flags:</p>

<ul>
<li>MMIO: --enable-mmio or --disable-mmio (default enabled)</li>
<li>ASIO: --enable-asio or --disable-asio (default enabled, if found)</li>
<li>JACK: --enable-jack or --disable-jack</li>
</ul>

<p>For example, to build Pd without MMIO support:</p>

<pre>./configure --disable-mmio</pre>

<p>Note: Because of license restrictions, Pd cannot distribute the ASIO SDK source files. If you want to build Pd with ASIO support, see <a href="chapter6.htm#s6.6.4">6.6.4 Windows ASIO support </a> for further instructions.</p>
<p>Once built Pd is built, you can either:</p>

<ul>
<li>build a Pd application directory for Windows (recommended)</li>
<li>build a Windows installer</li>
</ul>

<p>A Pd application directory is essentially a self-contained Pd package which should run out of the box. To build, simply use:</p>

<pre>make app</pre>

<p>This will create a &quot;pd-VERSION&quot; directory (ie. pd-0.48.1) which can then be used by running pd.exe in the bin directory and placed wherever on your system. More info &amp; options regarding the Pd app directory is provided next </p>

<p>To build a .msi Windows installer for Pd, see msw/build-nsi.sh.</p>

<p>Note: The standard &quot;make install&quot; requires Tcl/Tk and won't work
outside your Cygwin/Msys2 environment (if at all).</p>

<H4> <A href="#s6.6.1" id="s6.6.1"> 6.6.1. Building a Pd application </A> </H4>

<p>Directory pure-data/msw contains support files for building a Pure Data Windows
application, as it is built for the &lsquo;vanilla&rsquo; releases on msp.ucsd.edu.</p>

<p>As of Pd version 0.50, all releases are compiled using Dan Wilcox&rsquo;s scripts,
msw-app.sh, and optionally tcltk-dir.sh (which builds a version of TCL/TK in
case you don&rsquo;t already have one).</p>

<p>The Pd sources aren&rsquo;t completely self-contained: Because of licensing
restrictions, the ASIO support files are not included in the Pd source tree.
The msw-app.sh script presumes you&rsquo;ve downloaded the ASIO SDK and can point
msw-app.sh to it.</p>

<p>It&rsquo;s also possible to compile Pd using Visual C.  This is not managed
automatically but you can look in &ldquo;how-to-use-msvc.sh&rdquo; to see how it can be
done.  This compiler gives different warnings which are sometimes useful, and
refuses to compile code that has variable declarations in the middle of a
block.  It&rsquo;s a good idea to test pull requests against MSVC if you can.  The
file &ldquo;pdprototype.zip&rdquo; contains all the garbage that Pd needs in addition to its
own files, including tcl/tk.  MSVC compilation works in 32 bits only.</p>

<p>The scripts build-msw-32.sh and build-msw-64.sh are the ones used by Miller to
make Pd releases.  These files work on Linux only and will not work out of
the box unless your file tree resembles Miller&rsquo;s in some ways (pd source is in
~/pd for instance) but you can presumably make your own version if you need to.</p>

<p>But to first get things working, it&rsquo;s best to use msw-app.sh and tcltk-dir.sh
directly.</p>

<H4> <A href="#s6.6.2" id="s6.6.2"> 6.6.2. Pd application directory </A> </H4>

<p>Pd for Windows is essentially a stand-alone application directory which contains
the compiled binaries, resource files, and contextual information.</p>

<p>The basic layout is:</p>

<pre>pd
  /bin      &lt;- pd binaries
  /doc      &lt;- built in docs &amp; help files
  /extra    &lt;- core externals
  /font     &lt;- included fonts
  /lib      &lt;- embedded Tcl/Tk frameworks
  /po       &lt;- text translation files
  /src      &lt;- Pd source header files
  /tcl      &lt;- Pd GUI scripts</pre>

<p>The Pure Data GUI utilizes the Tk windowing shell aka &ldquo;wish##.exe&rdquo; at runtime
which is included with Pd in the /bin directory. A Pure Data app directory
includes both the Pd binaries and resources as well as a precompiled Tk.</p>

<H5> <A href="#s6.6.2.1" id="s6.6.2.1"> 6.6.2.1. Windows app bundle helpers </A> </H5>

<ul>
<li>msw-app.sh: creates a Pd app directory for Windows using precompiled Tcl/Tk</li>
<li>tcltk-dir.sh: downloads and builds Tcl/Tk for Windows</li>
</ul>

<p>These scripts complement the autotools build system described in INSTALL.txt and
are meant to be run after Pd is configured and built. The following usage, for
example, downloads and builds 32 bit Tk 8.6.8 which is used to create
a Windows pd-0.48-1 directory:</p>

<pre>msw/tcltk-dir.sh 8.6.8
msw/msw-app.sh --tk tcltk-8.6.8 0.48-1
</pre>

<p>Both msw-app.sh &amp; tcltck-dir.sh have extensive help output using the &ndash;help
commandline option:</p>

<pre>msw/msw-app.sh --help
msw/tcltk-dir.sh --help
</pre>

<p>The msw-app.sh script automates building the Pd app directory and is used in the
&ldquo;make app&rdquo; makefile target. This default action can be invoked manually after
Pd is built:</p>

<pre>msw/msw-app.sh 0.55-0
</pre>

<p>This builds a &ldquo;pd-0.55-0&rdquo; directory using the default copy of Tk. If you omit
the version argument, a &ldquo;pd&rdquo; directory is built. The version argument is only
used as a suffix to the directory name.</p>

<p>The &ldquo;msw/pdprototype.tgz&rdquo; archive contains the basic requirements for running Pd
on Windows: a precompiled copy of Tcl/Tk and various .dll library files. This is
the default Tcl/Tk when using msw-app.</p>

<p>If you want to use a newer Tcl/Tk version or a custom build, you can specify the
version or directory via commandline options, for example:</p>

<pre># create pd-0.48-1 directory, download and build Tcl/Tk 8.5.19
msw/msw-app.sh --tk 8.5.19 0.48-1

# create pd-0.48-1 directory, use Tcl/Tk 8.5.19 built with tcltk-dir.sh
msw/msw-app.sh --tk tcltk-8.5.19 0.48-1
</pre>

<p>Note: Depending on which version of Tcl/Tk you want to use, you may need to set
the Tk Wish command when configuring Pd. To build Pd to use Tk 8.6:</p>

<pre>./configure --with-wish=wish86.exe
make
</pre>

<p>The tcltk-dir.sh script automates building Tcl/Tk for Windows, either from the
release distributions or from a git clone:</p>

<pre># build tcltk-8.5.19 directory with Tcl/Tk 8.5.19
msw/tcltk-dir.sh 8.5.19

# build tcltk-master-git with the latest master branch from git
msw/tcltk-dir.sh --git master-git
</pre>

<p>Once your custom Tcl/Tk is built, you can use it as the Tk directory source for
msw-app.sh with the -t/&ndash;tk option:</p>

<pre># build Pd with a custom Tcl/Tk 8.6.8 directory
msw/msw-app.sh -t tcltk-8.6.8
</pre>

<p>Downloading and building Tcl/Tk takes some time. If you are doing lots of builds
of Pd and/or are experimenting with different versions of Tcl/Tk, building the
tcltk directories you need with tcltk-dir.sh can save you some time as they
can be reused when (re)making the Pd app directory.</p>

<p>Usually, it&rsquo;s best to use stable releases of Tcl/Tk. However, there are times
when building from the current development version is useful. For instance,
if there is a bug in the Tcl/Tk sources, you can then see if there is a fix for
this in the Tcl/Tk development version on GitHub. If so, then you can test by
using the tcltk-dir.sh &ndash;git commandline option.</p>

<p>The tcltk-dir.sh script tries to detect if it&rsquo;s building in a 64 bit
environment, ie. MinGW 64. If this detection fails, you can force 64 bit with
the &ndash;64bit option:</p>

<pre># force 64 bit Tcl/Tk 8.6.8 build
tcltk-dir.sh --64bit 8.6.8
</pre>

<H4> <A href="#s6.6.3" id="s6.6.3"> 6.6.3. pdfontloader </A> </H4>

<p>Tk cannot load local font files by default on Windows. Pd accomplishes this
through a tiny, custom Tcl extension, pdfontloader.dll. On initialization, the
Pd GUI tries to load pdfontloader and, if successful, tries to load the included
Pd font.</p>

<p>Currently, pdfontloader.dll is pre-built and included within the pdprototype.tgz
tarball. To build pdfontloader, see <a href="https://github.com/pure-data/pdfontloader" target="_blank">https://github.com/pure-data/pdfontloader</a>
source.</p>

<H4> <A href="#s6.6.4" id="s6.6.4"> 6.6.4. ASIO support </A> </H4>

<p>In order to build ASIO support into Pd on Windows, you need to download the
ASIO sources from Steinberg directly. Their license does not let us
redistribute their source files.</p>

<p>Install the ASIO SDK by doing the following:</p>

<ul>
<li>1. Download the ASIO SDK: <a href="https://www.steinberg.net/en/company/developer.html" target="_blank">https://www.steinberg.net/en/company/developer.html</a></li>
<li>2. Uncompress asiosdk2.3.zip (or higher) into pure-data/asio/</li>
<li>3. remove the version number so that you get pure-data/asio/ASIOSDK</li>
</ul>

<p>Now build Pd and it should include ASIO as one of the audio backends.</p>

<H3> <A href="#s6.7" id="s6.7"> 6.7. Cross-compilation for Windows on Linux </A> </H3>

<p>You can also build a Windows binary of Pd on a Linux system, using a cross-compilation toolchain.</p>
<p>For Debian based systems (e.g. Ubuntu), you can install the toolchain with:</p>

<pre>sudo apt-get install build-essential automake autoconf libtool gettext
sudo apt-get install mingw-w64 mingw-w64-tools
sudo apt-get install nsis</pre>

<p>The &quot;mingw-w64&quot; package will install the cross compilation toolchains for both 32bit (g++-mingw-w64-i686, binutils-mingw-w64-i686) and 64bit (g++-mingw-w64-x86-64, binutils-mingw-w64-x86-64).</p>
<p>The &quot;nsis&quot; package is purely optional, and only needed if you want to build the installer.</p>
<p>You must tell configure that you want to cross-compile for a given architecture via the &quot;--host&quot; configure flag.</p>
<p>For example, to build a 32 bit Pd:</p>

<pre>./configure --host=i686-w64-mingw32</pre>

<p>Similarly, to build a 64 bit Pd without ASIO support:</p>

<pre>./configure --disable-asio --host=x86_64-w64-mingw32</pre>

<p>If all went well, you should now be ready to build Pd, as explained in the instructions above in the &quot;Windows&quot; section:</p>

<pre>make app</pre>

<H3> <A href="#s6.8" id="s6.8"> 6.8. Makefile build </A> </H3>

<p>Alternatively, and often more simply, to the autotools build, you can use the fallback makefiles in the src directory:</p>

<ul>
<li>src/makefile.gnu: GNU/Linux</li>
<li>src/makefile.mac: macOS</li>
<li>src/makefile.msvc: Windows with Microsoft Visual C</li>
<li>src/makefile.mingw: Windows with MinGW GCC</li>
</ul>

<p>On Linux, for example, run the GNU-specific makefile in the src directory:</p>

<pre>cd src
make -f makefile.gnu</pre>

<p>You can then run directly out of the bin directory without installing:</p>

<pre>cd ../bin
./pd</pre>

<p>For Microsoft Visual C, first build Pd with the MS VC makefile and then build each external in the extra directory:</p>

<pre>cd src
make -f makefile.msvc
cd ../extra/bob~
make pd_nt
cd ../bonk~ &amp;&amp; make pd_nt
cd ../choice &amp;&amp; make pd_nt
cd ../fiddle~ &amp;&amp; make pd_nt
...</pre>

<p>To install Pd to your system on Linux, macOS, &amp; MinGW (Windows), use the &quot;install&quot; makefile target. For Linux, this is:</p>

<pre>make -f makefile.gnu install</pre>

<p>Once installed, you should now be able to run Pd from the commandline:</p>

<pre>pd</pre>

<p>If want to uninstall, simply run the &quot;uninstall&quot; makefile target:</p>

<pre>make -f makefile.gnu uninstall</pre>

<p>On macOS, you can build a clickable Pd .app bundle using the supplemental build
scripts in the mac directory (see <a href="chapter6.htm#s6.5.1">6.5.1 macOS resources</a>
for more info).</p>


<H3> <A href="#s6.9" id="s6.9"> 6.9. Troubleshooting </A> </H3>

<p>Let us know if you run any issues with building or installing Pd:</p>

<ul>
<li>send an email to the Pd-List: <a href="https://lists.puredata.info/listinfo/pd-list" target="_blank">https://lists.puredata.info/listinfo/pd-list</a></li>
<li>open an issue: <a href="https://github.com/pure-data/pure-data/issues" target="_blank">https://github.com/pure-data/pure-data/issues</a></li>
<li>post to the Pd forum: <a href="https://forum.pdpatchrepo.info" target="_blank">https://forum.pdpatchrepo.info</a></li>
</ul>

<p>Please include information involved with your problem such as:</p>

<ul>
<li>information about your system: OS version, libraries installed, etc</li>
<li>configure or make output including error lines</li>
<li>steps you took: configuration options, etc</li>
</ul>

</div>
<div class="nav nav-bottom">
    <div class="nav-back"><A href="chapter5.htm">&lt; Chapter 5: Current status</A></div>
    <div class="nav-home"><A href="../index.htm#s6">Table of contents</A></div>
    <div class="nav-forward"></div>
</div>

</BODY>
</HTML>