Difference between revisions of "MacOS/Quartz"

From GnuCash
Jump to: navigation, search
(GnuCash's many other requirements)
(gnucash-help is gnucash-manual as of GnuCash 5.0)
 
(255 intermediate revisions by 22 users not shown)
Line 1: Line 1:
This page describes the process by which I was able to get GnuCash 2.1.1 running with the Gtk+ on Mac OS X libraries. These libraries build on top of Apple's Quartz graphics/windowing system, making the resulting GnuCash application entirely independent of X11. This means also that the resulting GnuCash executable runs as its own independent application in the Mac OS X sense. For example, it gets its own entry in the Dock, rather than being subsumed into the X11 entry. Note, however, this is a lengthy process that involves compiling many source code distributions of various packages, some of which need minor edits (I haven't had a chance to make proper patchfiles). See [[MacOSXInstallation]] for the summary of other methods of installing GnuCash on the Mac, which use X11 but are much more straightforward.
+
{{Lowercase title}}
 +
[[Category: MacOS]]
 +
==Downloads==
 +
{{Macos_Downloads}}
  
=== Overview ===
+
==Overview==
 +
GnuCash can be built to run more or less natively on macOS -- meaning without X11. Better yet, the build is almost automatic.
  
The sequence of steps here
+
This page describes the procedure to build GnuCash with the Quartz environment. You can also use MacPorts: The details are described at [[MacOS/MacPortsDetail]]. If you already have MacPorts installed, you should use that procedure, as gtk-osx doesn't work well with a MacPorts installation.  
worked for me one time on a G4 Power PC running Mac OS X 10.4. I'm trying to automate this process using MacPorts so
 
that I can reproduce it, won't have to do it again by hand, and can upgrade practically as newer versions of the components are released. (If that gets to a workable
 
state, I'll update these instructions.)
 
  
January 2008: I (jralls) have successfully run this on a MacPro with 10.5 (Leopard), with a few changes because of new dependencies. I've taken out all but one of the version numbers (for guile, see below) because what's the point of going through all of this with old versions? What's more, GTK+ Mac now builds with an automated tool (jhbuild) which retrieves latest-and-greatest versions, many via subversion from development trees, so trying to use older versions will cause trouble. http://a.sotirov.net/2008/building-gnucash-on-mac-osx/ provides a much simpler way to build an XWindows version of gnucash, albeit without support for quotes or ofx.  
+
If you want to have a clickable GnuCash.app to put in your Applications folder, this is the solution to use. If you want to be able to easily customize your installation, this is also the solution for you. Don't want all of the extra stuff that MacPorts drags in? Well, this might be a bit better... but GnuCash is notorious for its huge list of dependencies. Want to keep up with the latest work from the Gnome developers? You can set up this solution to get many of its packages directly from source-code-control. That's a double-edged sword, of course, because if a build gets broken, you're pretty well stuck until the developers for that package fix it.  
  
 +
A build will consume about 5 gigabytes of disk space and typically take several hours to run.  The initial build, which includes pulling down sources from all dependencies, can take days, depending on how often network errors interrupt the process, and how quickly they are noticed.
  
Before you begin, there are a
+
This build integrates Gnucash menus with the Mac menubar at the top of the screen. About, Preferences, and Quit are in the "GnuCash" menu (it's named "gnucash-bin" when you run from the command line) in standard Mac style. Standard accelerator keys like Command-Q (quit), Command-S (save), and Command-O (Open) work as well. A patch to Gtk+ allows copy and paste in the register pages.
few important caveats: First, a number of the modifications below are
 
only for the sake of getting GnuCash to run. They're not appropriate
 
for using these packages with other software. That's why it's
 
important to keep this installation segregated from other software on
 
your computer. Second, as the Gtk+ on Mac OS X describes itself, it's
 
a work in progress and not ready for general use. There are likely
 
unknown bugs lurking.  I would not recommend this build for use with
 
any really important data.  That being said, I have found the
 
usability over the past few days to be fine, I think it looks nicer
 
than the X11 version, and it's nice not to have to invoke X11.
 
Anyhow, here goes:
 
  
=== Basic Gtk+ build ===
+
==Support==
<ol>
+
This procedure depends on the [https://wiki.gnome.org/action/show/Projects/GTK+/OSX Gnome Gtk-OSX project]. Support for that is provided via the [https://mail.gnome.org/mailman/listinfo/gtk-osx-users-list gtk-osx-users-list@gnome.org] mailing list. Questions, comments, or suggestions about Gnucash should be directed to the appropriate Gnucash mailing list ([https://lists.gnucash.org/mailman/listinfo/gnucash-devel gnucash-devel] for development versions (git master) or [https://lists.gnucash.org/mailman/listinfo/gnucash-user gnucash-user] for release (3.x, git maint).)
<li>Install git and subversion from MacPorts or Fink.</li>
 
<li>Create a fresh new user account (e.g. "gtkbuild") ''without'' the MacPorts or Fink environment variables and path, and link just the git/subversion executables into a directory added to gtkbuild's PATH.</li>
 
<li>Follow the instructions to build gtk+ at http://developer.imendio.com/projects/gtk-macosx/build-instructions:
 
<ol>
 
  <li> First do the "bootstrap" </li>
 
  <li> Then the "core" </li>
 
  <li> And then build all of the modules in the "Extra:" list printed when you execute <code>gtk-osx-build help</code>, one by one in the order on that list.</li>
 
</ol>
 
<li> Execute <code>gtx-osx-build shell</code> to get the proper environment, and execute all further commands in the resulting shell.</li>
 
</ol>
 
  
Update January 2008:
+
==Preliminaries==
 +
Read [https://wiki.gnome.org/Projects/GTK%2B/OSX/Building Building Gtk-OSX] and scan the [https://wiki.gnome.org/Projects/Jhbuild jhbuild docs].
 +
This procedure is based on both. '''Note well the [https://wiki.gnome.org/action/show/Projects/GTK/OSX/Building#Prerequisites warnings about Homebrew, MacPorts, and Fink!]''' Creating a separate user for building and packaging GnuCash is the easiest work-around if you've used any of those systems in your regular userid.
  
This procedure is now controlled by a Python program called jhbuild. Git isn't needed anymore, and subversion is provided by Leopard. If you're still on an older system, you'll need to get it separately. There's no need for a separate userid, either, but you will want to assign build and install directories in your .jhbuildrc-custom. (I used /usr/local/gnome and /usr/local/src/gnome). The instructions at the link above will take you through installing jhbuild and its environment, then building GTK+.
+
First download [https://gitlab.gnome.org/GNOME/gtk-osx/raw/master/gtk-osx-setup.sh gtk-osx-setup.sh] by clicking the link or from the command line:
 +
<syntaxhighlight lang="sh">
 +
curl -O -L https://gitlab.gnome.org/GNOME/gtk-osx/raw/master/gtk-osx-setup.sh
 +
</syntaxhighlight>
 +
and run it from the command line. Gtk now requires Python3 to build and Apple provides Python3 only on MacOS 10.15 Catalina, so it will first set up a Python3 virtual environment, then install jhbuild and configure what it needs to run. It will ask if you want to install CPython. You do.
  
Be sure to do the rest of your building inside the shell created by  
+
It defaults to installing everything in <tt>$HOME/.new_local</tt>. If you prefer to install somewhere else, set the environment variables <tt>DEVPREFIX</tt> and <tt>PYTHONUSERBASE</tt> to that directory before running <tt>gtk-osx-setup.sh</tt>. One way to do that is inline with the command, e.g.
<code>
+
<syntaxhighlight lang="sh">
 +
DEVPREFIX=$HOME/.jhbuild_root PYTHONUSERBASE=$HOME/.jhbuild_root ./gtk-osx-setup.sh
 +
</syntaxhighlight>
 +
There are some other directory customizing environment variables, see the list in <tt>gtk-osx-setup.sh</tt>
 +
Default or not, you'll want to add the install location's <tt>bin</tt> directory to <tt>$PATH</tt>.
 +
 
 +
JHBuild is configured to build GnuCash via [http://github.com/gnucash/gnucash-on-osx/raw/master/jhbuildrc-custom <code>jhbuildrc-custom</code>]. Download this file to your home directory either by clicking the link and moving the downloaded file or from the command line:
 +
<syntaxhighlight lang="sh">
 +
curl -O -L https://github.com/gnucash/gnucash-on-osx/raw/master/jhbuildrc-custom
 +
</syntaxhighlight>
 +
and place it in <tt>$HOME/.config</tt>--unless you've set something different in <tt>$XDG_CONFIG_HOME</tt>, in which case put it there.
 +
 
 +
OS X 10.11 added a security feature called [https://developer.apple.com/library/prerelease/mac/documentation/Security/Conceptual/System_Integrity_Protection_Guide/  System Integrity Protection] or SIP. One "feature" is that it strips linker environment variables (the ones starting with LD_ and DYLD_) from the environment when a "system" program does a fork/exec. For our purposes "system program" means one installed in <tt>/bin</tt> or <tt>/usr/bin</tt>, in particular <tt>/bin/sh</tt>.
 +
 
 +
The Guile compiler, '''guiled''', is a shell script that as written uses '''/bin/sh''' to set the prefix then execs guile to run a compilation script. That fails in the presence of SIP.
 +
 
 +
One can get around this by disabling SIP, but that's a whole-system change that requires a reboot, and SIP clearly has significant security benefits. Don't do that.
 +
 
 +
The other workaround is to use a shell that isn't in <tt>/bin</tt> or <tt>/usr/bin</tt>. One can just copy <tt>/bin/bash</tt> to one's user-level bin directory. <tt>gtk-osx-setup.sh</tt> does that for you, putting it in the install location's <tt>bin</tt> directory.
 +
 
 +
The default build location is <tt>$HOME/gnucash</tt> with subdirectories <tt>src</tt>, <tt>build</tt>, and <tt>inst</tt> for unpacking the sources, building, and installation respectively. You can change that by setting the environment variable <tt>PREFIX</tt>, e.g. <SyntaxHighlight lang="sh">
 +
PREFIX=/opt/gnucash jhbuild bootstrap-gtk-osx
 +
PREFIX=/opt/gnucash jhbuild build
 +
</SyntaxHighlight> You can make finer-grained changes by editing <tt>jhbuildrc-custom</tt>.
 +
 
 +
==== setup_sdk ====
 +
With no arguments (the default) <code>setup_sdk()</code> will configure the build for your system. Unless you're building for distribution we recommend that you do this.
 +
 
 +
If you have Xcode 7 (shipped with OS X 10.9 (Mavericks)) or later you can build for any version from 10.6 on with the included SDK by calling (e.g.)<SyntaxHighlight lang="sh">
 +
setup_sdk("10.6", native, ["i386"])
 +
</SyntaxHighlight> Note, however, that some users have noted linkage problems when doing this.
 +
It is safest to build GnuCash on the earliest macOS version you intend to support.
 +
The GnuCash 2.6.x application bundles were built for Mac OS X 10.5 and later. To do likewise, please see [https://wiki.gnome.org/Projects/GTK+/OSX/Building#Building_for_Older_Versions_of_Mac_OS_X Building for Older Versions of Mac OS X]. You'll use <syntaxhighlight lang="sh">
 +
setup_sdk("10.5", "10.5"["i386"])
 +
</syntaxhighlight>
 +
;Notes:
 +
:* GnuCash v2.7.x and later use the CMake buildsystem.
 +
:* GnuCash v2.7.x and later requires MacOS X 10.9 ("Mavericks") or later.
 +
:* GnuCash v3.900 and later requires MacOS 10.13 ("High Sierra") or later because it uses C++17 and the attendant standard library.
 +
:* Apple has removed 32-bit runtime support from macOS 10.15, so you'll need to build on an older version of macOS if you want <tt>arch='i386'</tt>.
 +
:* Apple Silicon is first supported in macOS 11. We have never successfully cross-compiled the Gtk stack so you'll probably need an Apple Silicon Mac to build an Apple Silicon native GnuCash. Note that as of October 2022 WebKitGtk isn't able to find its loadable modules so that reports don't render in GnuCash.
 +
:* PowerPC similarly requires building on a PowerPC machine.
 +
 
 +
Make any changes by editing <tt>jhbuildrc-custom</tt>
 +
 
 +
==Building==
 +
 
 +
Once all of the preliminaries are complete, run:
 +
<syntaxhighlight lang="sh">
 +
jhbuild bootstrap-gtk-osx
 +
jhbuild build
 +
</syntaxhighlight>
 +
 
 +
===Building for Development===
 +
 
 +
Please see [[Development]] for general guidelines and lots of helpful links.
 +
 
 +
If you intend to contribute your work to the GnuCash project please subscribe to [https://wiki.gnucash.org/wiki/Mailing_Lists#Mailing_Lists_for_Development_Topics the gnucash-devel list] and coordinate your work with the core developers '''before''' starting.
 +
 
 +
You'll need to work with the appropriate source code repository rather than the release tarball from the procedure so far. [[Git]] provides details on our repository and has some help for developers who aren't yet familiar with the [http://git-scm.com/ git] version control system. Open <tt>jhbuildrc-custom</tt> in your text editor and find the section
 +
<syntaxhighlight lang="Python">
 +
#Select which modules to build. The only difference is which gnucash
 +
#module (and all of the dependencies, see above) get built. "
 +
modules = ["meta-gtk-osx-bootstrap", "meta-gnucash-stable"]
 +
#modules = ["meta-gtk-osx-bootstrap", "gnucash-unstable"]
 +
#modules = ["meta-gtk-osx-bootstrap", "gnucash-git"]
 +
#branches["gnucash-git"] = (None, "maint")
 +
</syntaxhighlight>
 +
and change it to
 +
<syntaxhighlight lang="Python">
 +
#Select which modules to build. The only difference is which gnucash
 +
#module (and all of the dependencies, see above) get built. "
 +
#modules = ["meta-gtk-osx-bootstrap", "meta-gnucash-stable"]
 +
#modules = ["meta-gtk-osx-bootstrap", "gnucash-unstable"]
 +
modules = ["meta-gtk-osx-bootstrap", "gnucash-git"]
 +
branches["gnucash-git"] = (None, "maint")
 +
</syntaxhighlight>
 +
:;Note the <tt>branches</tt> line: It will build the current ''stable'' branch; to build the ''development'' branch, the one leading to the next major release, change <tt>maint</tt> to <tt>master</tt>. You may also want to change the prefix directory in the line above that block.
 +
 
 +
====Command-line builds====
 +
Once you have your initial build finished you'll start editing sources (they'll be in <tt>$HOME/gnucash-stable/src/gnucash-git</tt> unless you changed the <tt>prefix</tt> in <tt>jhbuilrc-custom</tt>) and you'll want to build and run the unit tests. Start a <tt>jhbuild</tt> shell and change directory to the build directory:
 +
<syntaxhighlight lang="sh">
 
jhbuild shell
 
jhbuild shell
</code>
+
cd %PREFIX/../build/gnucash-git
 +
</syntaxhighlight>
 +
From there you can run the usual shell commands like <tt>cmake</tt> and <tt>ninja</tt>.
 +
 
 +
===Building with Xcode===
 +
It's possible to build GnuCash using Apple's Xcode IDE. To make it work first do a regular build as above to get all of the dependencies set up.
 +
 
 +
Now create a new build directory and ```cd``` to it but do *not* start a jhbuild shell, just export the following environment variables to simplify the cmake invocation:
 +
<syntaxhighlight lang="sh">
 +
export PREFIX=/full/path/to/prefix
 +
export PATH=$PATH:$PREFIX/bin
 +
export SRCROOT=$PREFIX/../src
 +
</syntaxhighlight>
 +
making any required changes. '''Be sure to make different build directories for the maint and the master branches'''.
 +
 
 +
Now create the xcodeproject with cmake:
 +
 
 +
<syntaxhighlight lang="sh">
 +
cmake -G Xcode -D CMAKE_INSTALL_PREFIX=$PREFIX -D GTEST_ROOT=$SRCROOT/googletest $SRCROOT/gnucash-git
 +
</syntaxhighlight>
 +
 
 +
If you're building from a tarball you'll need to change the source directory at the end of the line.
 +
 
 +
For some newer versions of Xcode cmake seems unable to determine the C compiler and tries to use ```ld```. If you encounter errors during Cmake or building saying that `ld` doesn't accept some option try adding
 +
<syntaxhighlight lang="sh">
 +
  -D CMAKE_C_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/Xcodetoolchain.default/usr/bin/clang
 +
</syntaxhighlight>
 +
to the cmake command line. Adjust the path as needed if the Xcode you're using isn't <code>/Applications/Xcode.app</code>.
 +
 
 +
;Notes:
 +
:* Because all current branches of GnuCash use C++ features that don't compile on or for earlier versions, GnuCash requires MacOS 10.13 (High Sierra) or later.
 +
:* The dependencies for GnuCash have changed from the 2.x releases. The most significant are that major Linux distributions have dropped support for WebKit1Gtk, so we had to enable support for WebKit2Gtk and that in turn requires that GnuCash switch to Gtk3. We've rewritten several modules in C++ and are using [https://github.com/google/googletest/ GoogleTest] for new unit tests and the [https://www.boost.org Boost Libraries] for several language extensions. The register has been fixed to no longer use the obsolete <code>libgnomecanvas</code> and the small part of <code>libgoffice</code> that the CSV importer required has been copied into GnuCash sources.
 +
 
 +
===Documentation===
 +
The gnucash documentation is [http://www.gnucash.org/docs.phtml online], of course, but if you want a local copy, you can build the modules <tt>gnucash-docs</tt> or <tt>gnucash-docs-git</tt>. Just add whichever one you want to your "modules" argument. If you're using <tt>gnucash-docs-git</tt> you might also want to select the branch by adding a line
 +
<syntaxhighlight lang="Python">
 +
branches["gnucash-docs-git"] = (None, "maint")
 +
</syntaxhighlight>
 +
setting <tt>"maint"</tt> or <tt>"master"</tt> as you prefer.
 +
 
 +
===Debugging===
 +
To get a debugging build, add the line
 +
<tt>setup_debug()</tt>
 +
to jhbuildrc-custom. Beware, though, that WebKit doesn't build with debugging enabled. I usually build everything first without debugging enabled, then enable it and rebuild <SyntaxHighlight lang="sh">
 +
jhbuild buildone --force --clean
 +
</SyntaxHighlight> the packages you want to debug. Most of the time you can get by with just glib and gnucash, but depending on what you're working on, you might also want gtk+, gwenhywfar, aqbanking, or libdbi.
 +
 
 +
==Running from the commandline==
 +
 
 +
Now you're ready to try it out: <syntaxhighlight lang="sh">
 +
$PREFIX/bin/gnucash
 +
</syntaxhighlight>
 +
$PREFIX is the path to where you've built gtk; you can fill it in yourself or use <tt>jhbuild shell</tt> to set it for you.
 +
 
 +
==Making a Bundle==
 +
So far so good, but you don't really want to have to open a Terminal window every time you want to use GnuCash, now do you? Of course not. You want a nice icon in your Applications folder (and maybe in the Dock) to click on when you run GnuCash. Here's how to do this:
 +
 
 +
'''N.B.''' This procedure works ''only'' with GnuCash built according to the above instructions.
 +
 
 +
:Clone [https://gitlab.gnome.org/GNOME/gtk-mac-bundler.git the bundler], cd into the cloned gtk-mac-bundler directory, and <tt>make install</tt>
 +
:Create a directory somewhere convienient (we'll call it <tt>gnucash-bundler</tt> from now on), cd to it, and download [https://raw.github.com/Gnucash/gnucash-on-osx/master/gnucash-bundler/gnucash.bundle gnucash.bundle], [https://raw.github.com/Gnucash/gnucash-on-osx/master/gnucash-bundler/Info.plist Info.plist], and [https://raw.github.com/Gnucash/gnucash-on-osx/master/gnucash-bundler/gnucash.icns gnucash.icns] into it.
 +
 
 +
Look through gnucash.bundle and adjust the paths to match your installation.
 +
 
 +
;Documentation: The bundle includes documentation. If you've built it, great, no problem. You need to have it installed for the Help menu items to work. If you didn't build it and you don't want to, then comment out or remove the lines <syntaxhighlight lang="xml">
 +
  <data dest="${bundle}/Contents/Resources/en.lproj/GnuCash Help/">
 +
    ${prefix}/share/gnome/help/gnucash/C/gnucash-manual
 +
  </data>
 +
 
 +
  <data dest="${bundle}/Contents/Resources/en.lproj/GnuCash Guide/">
 +
    ${prefix}/share/gnome/help/gnucash/C/gnucash-guide/
 +
  </data>
 +
 
 +
  <data dest="${bundle}/Contents/Resources/de.lproj/GnuCash Help/">
 +
    ${prefix}/share/gnome/help/gnucash/de_DE/gnucash-manual
 +
  </data>
 +
 
 +
  <data dest="${bundle}/Contents/Resources/de.lproj/GnuCash Guide/">
 +
    ${prefix}/share/gnome/help/gnucash/de_DE/gnucash-guide/
 +
  </data>
 +
 
 +
  <data dest="${bundle}/Contents/Resources/it.lproj/GnuCash Help/">
 +
    ${prefix}/share/gnome/help/gnucash/it_IT/gnucash-manual
 +
  </data>
 +
 
 +
  <data dest="${bundle}/Contents/Resources/it.lproj/GnuCash Guide/">
 +
    ${prefix}/share/gnome/help/gnucash/it_IT/gnucash-guide/
 +
  </data>
 +
 
 +
  <data dest="${bundle}/Contents/Resources/ja.lproj/GnuCash Guide/">
 +
    ${prefix}/share/gnome/help/gnucash/ja_JP/gnucash-guide/
 +
  <data dest="${bundle}/Contents/Resources/pt.lproj/GnuCash Help/">
 +
    ${prefix}/share/doc/gnucash-docs/pt/gnucash-manual/
 +
  </data>
  
Otherwise you'll need to set a bunch of environment variables at various stages.
+
  <data dest="${bundle}/Contents/Resources/pt.lproj/GnuCash Guide/">
 +
    ${prefix}/share/doc/gnucash-docs/pt/gnucash-guide/
 +
  </data>
 +
 
 +
  <data dest="${bundle}/Contents/Resources/ru.lproj/GnuCash Guide/">
 +
    ${prefix}/share/doc/gnucash-docs/ru/gnucash-guide/
 +
  </data>
 +
</syntaxhighlight> To comment out XML code, surround it like so: <SyntaxHighlight lang="xml">
 +
<!-- stuff to be commented out -->
 +
</SyntaxHighlight> Note that comments cannot contain "--".
  
=== GnuCash's many other requirements ===
+
You're ready to make your bundle: <SyntaxHighlight lang="sh">
Next is a long series of download-configure-build-install cycles to get all of the packages GnuCash depends on.  For each one, I give the package name and version, a URL to download from, and a configure command.  If there are no other instructions, you download the tarball from the given URL, extract it (e.g. <code>tar -zxvf <tarball filename></code>,  cd into the top level directory extracted, execute the configure command, and then execute <code>make</code> and then <code>make install</code>. The "standard configure" command listed in many cases below is <code>./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-xlib</code> (probably in many cases not all of these options are necessary or even operational, it's just convenient to have one command that can be used in as many cases as possible.) Note that there's nothing magic about /opt/gtk; you can use anything you want for a prefix (but you should stay away from places used by OSX, Fink, or MacPorts). If you leave off the prefix, most of these packages will default to installing in /usr/local.
+
jhbuild shell                #to set up the environment for the bundler
 +
export PATH=$PREFIX/bin:$PATH #because jhbuild shell doesn't do this for some reason
 +
gtk-mac-bundler gnucash.bundle
 +
exit                          #quit the jhbuild shell
 +
</SyntaxHighlight>
  
(Jan 2008)In order to compile libgnomecanvas, which is required by libbonoboui, you'll need to add the X11 pkgconfig directory to PKG_CONFIG_PATH. For Leopard, do
+
And your bundle should be ready to go.
<code>
+
Try <tt>GnuCash.app/Contents/MacOS/GnuCash</tt> from the command-line so that you can see any error messages. If that works, try <tt>open GnuCash.app</tt>. If that works, then you can move GnuCash.app to your Applications folder and it's ready to use.  
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/X11/lib/pkgconfig
 
</code>
 
from inside the jhbuild shell.
 
  
Next get, build, and install the following additional libraries. GNOME means http://ftp.gnome.org/pub/GNOME/platform. You'll go down three levels, to major-version/version/sources, with major-version being something like 2.20 and version being like 2.20.1. SOURCES means http://ftp.gnome.org/pub/gnome/sources. In general you'll want the latest versions because jhbuild retrieves its sources directly from svn.
+
=== Bundling Oldstable ===
<ol>
 
  <li>readline, ftp://ftp.gnu.org/pub/gnu/readline, <code>./configure --prefix=/opt/gtk</code>. Yes, there's a libreadline already in the system libraries, but it's not gnu readline and it won't work. Note the patches subdirectory for the version you get. If you're building readline 5.2 on Leopard, you'll need at least patch 52-012, but you'll probably want to apply them all just on principle.</li>
 
  <li>guile 1.6.8, ftp://ftp.gnu.org/pub/gnu/guile, standard configure. Guile 1.8 is installed by jhbuild as part of GTK+ Mac, but for some reason it doesn't play well with gnucash. In particular, gnucash uses the construct <code>(map&nbsp;(lambda&nbsp;(foo)&nbsp;(bar)))</code>, which is perfectly valid scheme -- but guile 1.8 doesn't recognize <code>map</code> as a function name. To be safe, go to the source directory where you told jhbuild to build guile and run <code>make uninstall</code> <em>before installing guile-1.6.8</em></li>
 
  <li>Download slib3a4 from  http://swiss.csail.mit.edu/~jaffer/SLIB.html and unzip it. You then need to link the top-level directory created by the unzipping into the guile library directory:
 
<pre>
 
ln -s <slib directory> /opt/gtk/share/guile/1.6
 
mkdir /opt/gtk/share/guile/site
 
</pre>
 
If you prefer, you can skip the symbolic link and instead export SCHEME_LIBRARY_PATH=<slib&nbsp;directory>.<br>
 
Start guile and run the following lisp commands:
 
<pre>
 
$guile
 
guile> (use-modules (ice-9 slib))
 
guile> (require 'new-catalog)
 
guile> (quit)
 
</pre>
 
Slib is now ready to use.</li>
 
  <li>libIDL, GNOME, standard configure</li>
 
  <li>ORBit2, GNOME, standard configure</li>
 
  <li>GConf, GNOME, <code>./configure --prefix=/opt/gtk --enable-static --enable-shared --disable-scrollkeeper --disable-xlib</code> (note the --enable-static here)</li>
 
  <li>OpenSP, http://sourceforge.net/projects/openjade, <code>./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-doc-build</code></li>
 
  <li>libofx, http://libofx.sourceforge.net, <code>./configure --prefix=/opt/gtk --disable-static --enable-shared --with-opensp-includes=/opt/gtk/include/OpenSP --with-opensp-libs=/opt/gtk/lib/</code></li>
 
  <li>popt, http://rpm.net.in/mirror/rpm-4.4.x, <code>./configure --prefix=/opt/gtk --disable-static --enable-shared</code></li>
 
  <li>audiofile, GNOME, <code>./configure --prefix=/opt/gtk --disable-static --enable-shared</code></li>
 
  <li>esound, GNOME, <code>./configure --prefix=/opt/gtk --disable-static --enable-shared</code></li>
 
  <li>dbus and dbus-glib, http://www.freedesktop.org/wiki/Software/dbus/, for each one: <code>./configure --prefix=/opt/gtk --disable-static --enable-shared </code></li>
 
  <li>libart_lgpl, GNOME, standard configure (Jan 2008)</li>
 
  <li>libglade, GNOME, standard configure (Jan 2008)</li>
 
  <li>libgnomecanvase, GNOME, standard configure (Jan 2008)</li>
 
  <li>gnome-mime-data, gnome-vfs, libbonobo, libgnome, libbonoboui,  from GNOME, standard configure for each one.</li>
 
  <li>libgpg-error and libgcrypt, http://www.gnupg.org/download/index.en.html, standard configure. (Jan 2008)</li>
 
  <li>libtasn1, http://josefsson.org/gnutls/releases/libtasn1/, standard configure (Jan 2008)</li>
 
  <li>gnome-keyring, GNOME, standard configure</li>
 
  <li>Download and extract libgnomeui from GNOME<br>Under 2.18 the following was necessary:<br> In the libgnomeui directory: Comment out the following section of the configure script at line 23836:
 
<pre>
 
#    if test x$GNOME_HAVE_X11 != xyes ; then
 
#        { { echo "$as_me:$LINENO: error: libX11 not found" >&5
 
#echo "$as_me: error: libX11 not found" >&2;}
 
#  { (exit 1); exit 1; }; }
 
#    fi
 
</pre>
 
comment out line 845 of libgnomeui/gnome-ui-init.c:
 
<pre>
 
        /* XUngrabServer (GDK_DISPLAY ()); */
 
</pre>
 
But it wasn't for 2.21. <br>
 
<code>./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-xlib --without-x</code>, and make and make install.
 
  </li>
 
  <li>libgnomecups, SOURCES/libgnomecups, standard configure</li>
 
  <li>Download and extract libgnomeprint-2.18.0 from GNOME<br>Then, in the libgnomeprint directory, edit configure: You need the following line just after the "GLIB_GENMARSHAL" block; it was missing altogether in 2.18.1, and was just <code>LIBM=</code> in 2.18.3.
 
<pre>
 
  LIBM=" "
 
</pre>
 
And then <code>./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-xlib --disable-gtk-doc</code>.<br>
 
Next you need to change line 945 of libgnomeprint/Makefile from:
 
<pre>
 
$(FLEX_PATH) -P_gnome_print_filter_parse_yy $^
 
</pre>
 
to
 
<pre>
 
$(FLEX_PATH) -P_gnome_print_filter_parse_yy parse.l
 
</pre> and finally do make and make install. </li>
 
  <li>libgsf, SOURCES/libgsf, standard configure</li>
 
  <li>pcre, ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/, <code>./configure --prefix=/opt/gtk --disable-static --enable-shared --enable-utf8</code></li>
 
  <li>libgoffice, SOURCES/goffice, standard configure</li>
 
  <li>icon-naming-utils, http://tango.freedesktop.org/Tango_Icon_Library (Jan 2008)</li>
 
  <li>gnome-icon-theme, SOURCES/gnome-icon-theme, standard configure (Jan 2008)</li>
 
  <li>Download and extract gtkhtml from SOURCES/gtkhtml<br>Then, execute the configure command <code>GAIL_CFLAGS=" " GAIL_LIBS=" " ./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-xlib</code>;
 
The following was required for 3.15 but not for 3.17.90:
 
<ul>
 
<li>Delete line 260 of Makefile:
 
<pre>
 
a11y \
 
</pre></li>
 
<li>Delete ../a11y/gtkhtml-a11y.la from line 66 of src/Makefile, yielding
 
<pre>
 
$(am__DEPENDENCIES_1) \
 
</pre></li>
 
<li>Delete ../a11y/gtkhtml-a11y.la from line 569 of src/Makefile, yielding
 
<pre>
 
libgtkhtml_3_14_la_LIBADD = $(GTKHTML_LIBS) $(GAIL_LIBS) $(REGEX_LIBS)
 
</pre></li>
 
<li>Comment out line 3170 of src/gtkhtml.c:
 
<pre>
 
/* gtk_html_accessibility_init ();  */
 
</pre> and finally make and make install.</li></ul></li>
 
</ol>
 
  
<p>Note: While building the various gnome libraries I (jralls) encountered numerous uses of G_GNUC_FUNCTION and G_GNUC_PRETTY_FUNCTION. These should be replaced with __FUNCTION__ and __PRETTY_FUNCTION__; the original defines are in glib-2.0/glib/gmacros.h (which define them as empty for gcc 3.0 and later), but there isn't always an include chain leading back there.</p>
+
To bundle GnuCash version 2.6 and earlier you need [https://raw.github.com/Gnucash/gnucash-on-osx/master/gnucash-bundler/gnucash-oldstable.bundle gnucash-oldstable.bundle], [https://raw.github.com/Gnucash/gnucash-on-osx/master/gnucash-bundler/Info-oldstable.plist Info-oldstable.plist] instead of the corresponding ones listed above as well as
 +
[https://raw.github.com/Gnucash/gnucash-on-osx/master/gnucash-bundler/gnucash.launcher gnucash.launcher]. Older versions don't have the Portuguese or Russian Guide translations. Otherwise the procedure is the same.
  
=== GnuCash ===
+
=== Bundling from a Git Clone ===
 +
At present there are two active git branches, 'maint' and 'master'. Both use the primary bundling procedure above.
  
Finally you're ready for GnuCash itself: Downloaded and extract gnucash from gnucash.org.
+
=== Making a distribution ===
  
Edit configure and replace:
+
* Make a clean build including the documentation, making sure that you're not building any libraries with debugging. With all of the dependencies, the package is huge enough without it. Make sure that you're using the latest git masters for [http://gitlab.gnome.org/GNOME/gtk-mac-bundler gtk-mac-bundler] and [http://github.com/Gnucash/gnucash-on-osx  gnucash-on-osx].
<pre>
+
* Edit the version numbers and, if necessary, the copyright dates in Info.plist (or Info-unstable.plist).
-for ac_header in X11/Xlib.h glob.h
+
* make sure that $APPLICATION_CERT is set correctly with your Apple Developer Program certificate ID. gtk-mac-bundler uses the value of that environment variable to codesign the app bundle.
+for ac_header in glob.h
+
* Make a bundle as described above. Test it.
</pre>
+
* Make a directory named for the version that you're going to distribute and move the new bundle into it.
Where this line is will depend on what version of gnucash you have.
+
* Copy the scriptlet "FinanceQuote Update.app" from the previous version .dmg to the new distribution folder.
The original version of this page suggested defining the environment variable
+
* Copy AUTHORS, DOCUMENTORS, LICENSE, NEWS, and README from the GnuCash source directory to the distribution folder. Rename each file with a ".txt" suffix so that Finder will recognize it and enable QuickLook.
<pre>
+
* Open /Applications/Utilities/Disk Utility.app and select File>New>Disk Image from Folder in the menu. Select your installation directory in the first chooser and name it appropriately in the second (<tt>Gnucash-Intel-X.Y-Z.dmg</tt> where X.Y is the GnuCash version and Z is the serial number of dmgs for that release, beginning with 1.)
  SCHEME_LIBRARY_PATH=/opt/gtk/share/guile/1.6/slib
+
* codesign the dmg with your Apple Developer Program certificate.
</pre>
+
* Get the SHA-256 hash of the .dmg with <SyntaxHighlight lang="sh">
but this isn't necessary if that's where you put (or linked) slib. If you put it somewhere else then you will need to define and export SCHEME_LIBRARY_PATH pointing to the slib directory.
+
shasum -a 256 Gnucash-Intel-X.Y-Z.dmg
For building gnucash 2.2.3 under Leopard, I made the following changes before building:
+
</SyntaxHighlight> and paste the result into the SourceForge README.txt, the Github release notes, the news article in <tt>gnucash-htdocs</tt>, and the release announcement email.
<ol>
+
* Upload both the resulting .dmg  to the correct version directory of Gnucash's file manager area on Sourceforge. If this is a stable release, check the "Mac" box on the options panel so that users viewing the project page with a Mac will see the new release in the big green button.
<li>In src/engine/SplitP.h,  
+
* Upload the .dmg to the release on Github.
<pre>
+
* Update the appropriate links on the Gnucash webpage.
@@ -149,7 +149,7 @@
 
Split * xaccSplitClone (const Split *s);
 
 
Split *xaccDupeSplit (const Split *s);
 
-G_INLINE_FUNC void mark_split (Split *s);
 
+void mark_split (Split *s);
 
 
void xaccSplitVoid(Split *split);
 
void xaccSplitUnvoid(Split *split);
 
</pre>
 
Needed because gcc-4.0.2 in Leopard inlines this into Split.c, but not into Transaction.c -- nor does it create a function in the library, leading to a link error (symbol not found: _mark_split)</li>
 
  
<li>In src/bin/gnucash.in,
+
==Accessibility==
<pre>
+
Gtk has its own accessibility library, atk. It doesn't use or support the Mac's accessibility functions; in particular, one must use the [https://wiki.gnome.org/Projects/Orca Orca] screen reader. This isn't provided in the application bundle as as far as we know there is no ready-made Mac build of it.
@@ -12,9 +12,10 @@
 
EXTRA_PATH="${EXTRA_PATH}@-PATH_SEPARATOR-@@-GNC_SCM_INSTALL_DIR-@"
 
GUILE_LOAD_PATH="${EXTRA_PATH}@-PATH_SEPARATOR-@${GUILE_LOAD_PATH}"
 
 
-EXTRA_LIBS="${GNC_MODULE_PATH}"
 
-EXTRA_LIBS="${EXTRA_LIBS}@-PATH_SEPARATOR-@@-GNC_LIB_INSTALLDIR-@"
 
-EXTRA_LIBS="${EXTRA_LIBS}@-PATH_SEPARATOR-@@-GNC_PKGLIB_INSTALLDIR-@"
 
+EXTRA_LIBS="${GNC_MODULE_PATH}:/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/:/usr/local/gtk/lib"
 
+#EXTRA_LIBS="${GNC_MODULE_PATH}"
 
+#EXTRA_LIBS="${EXTRA_LIBS}@-PATH_SEPARATOR-@@-GNC_LIB_INSTALLDIR-@"
 
+#EXTRA_LIBS="${EXTRA_LIBS}@-PATH_SEPARATOR-@@-GNC_PKGLIB_INSTALLDIR-@"
 
 
LD_LIBRARY_PATH="${EXTRA_LIBS}@-PATH_SEPARATOR-@${LD_LIBRARY_PATH}"
 
DYLD_LIBRARY_PATH="${EXTRA_LIBS}@-PATH_SEPARATOR-@${DYLD_LIBRARY_PATH}"
 
</pre>
 
  
This has the same effect as the libextra dance in the original mod above, which is making sure that the ImageIO framework gets access to its own libJPEG.dylib, and that the rest of gnucash can find its gnc and guile libraries.</li></ol>
+
==Helping Out==
  
Now run configure:
+
If you can work on one of these items, please pitch in! Some are Gnucash issues, some are issues with the Quartz implementation of Gtk, and some are integration issues. Join the [https://mail.gnome.org/mailman/listinfo/gtk-osx-devel-list gtk-osx-devel mailing list]  to coordinate your work with others.
<pre>
 
./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-gtk-docs --enable-ofx --disable-xlib
 
</pre>
 
followed by make && make install
 
  
The original version of this page (for gnucash 2.1.1 and Tiger) had the following procedure <em>after</em> installing:
+
==Example: Setting up a Development Environment==
<pre>
 
  mkdir /opt/gtk/libextra
 
  cd /opt/gtk/libextra
 
  ln -s ../lib/libgnc* ../lib/libguile* .
 
</pre>
 
Edit /opt/gtk/bin/gnucash as follows:  replace line 20, which is:
 
<pre>
 
DYLD_LIBRARY_PATH="${EXTRA_LIBS}:${DYLD_LIBRARY_PATH}"
 
</pre>
 
with the following two lines:
 
<pre>
 
DYLD_LIBRARY_PATH="/opt/gtk/lib/gnucash:/opt/gtk/libextra:${DYLD_LIBRARY_PATH}"
 
SCHEME_LIBRARY_PATH=/opt/gtk/share/guile/1.6/slib
 
</pre> and insert the following line:
 
<pre>
 
export SCHEME_LIBRARY_PATH
 
</pre> between:
 
<pre>
 
export DYLD_LIBRARY_PATH
 
</pre> and:
 
<pre>
 
exec gnucash-bin "$@"
 
</pre>
 
  
 +
====Platform====
 +
* M1 Mac running macOS Ventura 13.0.1
 +
* Existing user administrator account with homebrew installed
  
Now cross your fingers and try running it -- you can execute <code>gnucash</code> from any shell, and the application should come up right within Aqua. One difference in the startup is worth noting here: under X11, a window pops up with a progress bar showing the loading of the data file, and then the main Gnucash screen comes up (with Accounts, etc.) Under Quartz at least at the moment, the progress bar never appears so you just have to be patient while your file is loaded.
+
====Goal====
 +
* Create a new macOS user '''gnucash'''
 +
* Install a GnuCash development environment in the gnucash user account
 +
* Insulated the development environment from the homebrew installation
 +
* Build GunCash from git repo
  
As of January 2008, the splash screen now appears and the progress bar for the file load works.
+
====Steps====
  
Good luck!
+
# In the existing administrator account, use '''System Settings > Users & Groups > Add Account...'' to create the '''gnucash''' administrator account. Then, changing the bash version number as appropriate. <SyntaxHighlight lang="sh">
 +
brew install bash
 +
cp /opt/homebrew/Cellar/bash/5.2.15/bin/bash /Users/gnucash/Public/Drop\ Box
 +
chmod +a "user:gnucash deny add_file,search,add_subdirectory,delete_child,readattr,writeattr,writeextattr,readsecurity" /opt/homebrew
 +
</SyntaxHighlight>
 +
#* The development environment needs its own copy of bash, but at least in macOS 13, just copying '''/bin/bash''' doesn't work
 +
#* The first two commands provide a usable copy of bash to the gnucash user
 +
#* The '''chmod''' commands prevent the gnucash user from accessing the homebrew installation
 +
# Switch to the '''gnucash''' and <SyntaxHighlight lang="sh">
 +
cd $HOME
 +
curl -O -L https://gitlab.gnome.org/GNOME/gtk-osx/raw/master/gtk-osx-setup.sh
 +
chmod 755 gtk-osx-setup.sh
 +
./gtk-osx-setup.sh
 +
export PATH="$HOME/.new_local/bin:$PATH"
 +
cp ~/Public/Drop\ Box/bash $HOME/.new_local/bin
 +
curl -O -L https://github.com/gnucash/gnucash-on-osx/raw/master/jhbuildrc-custom
 +
mv jhbuildrc-custom .config
 +
echo 'branches["gnucash-git"] = (None, "master")' >> .config/jhbuildrc-custom
 +
sed -i '' -Ee 's/= _modules_stable/= _modules_git/' .config/jhbuildrc-custom
 +
PREFIX=/Users/gnucash/opt/gnucash jhbuild bootstrap-gtk-osx
 +
PREFIX=/Users/gnucash/opt/gnucash jhbuild build
 +
</SyntaxHighlight>
 +
# As of January 2023, the build failed on xmlsec1 due to a missing dependency in gnutls. The build stopped with a menu of several options.  The following patched the issue <SyntaxHighlight lang="sh">
 +
# Open another terminal and edit the following package config file
 +
nano /Users/gnucash/opt/gnucash/inst/lib/pkgconfig/gnutls.pc  # add -lgcrypt to the Libs line & save
 +
# Back in the original build terminal, select Go to phase "configure" option
 +
</SyntaxHighlight>
 +
# Install Finance::Quote from source <SyntaxHighlight lang="sh">
 +
PREFIX=/Users/gnucash/opt/gnucash jhbuild shell
 +
PREFIX=/Users/gnucash/opt/gnucash
 +
curl -L https://cpanmin.us | perl - App::cpanminus
 +
export PATH="$PATH:$HOME/perl5/bin"
 +
cpanm --local-lib=$PREFIX/lib/perl5 local::lib && eval $(perl -I $PREFIX/lib/perl5/lib/perl5 -Mlocal::lib)
 +
git clone https://github.com/finance-quote/finance-quote.git
 +
cd finance-quote
 +
cpanm install Dist::Zilla
 +
dzil authordeps --missing | cpanm --notest
 +
dzil listdeps --missing | cpanm --notest
 +
cpanm install Data::Dumper::Perltidy Smart::Comments
 +
dzil build
 +
cpanm Finance-Quote-1.55.tar.gz
 +
cpanm install JSON::Parse
 +
</SyntaxHighlight>

Latest revision as of 17:32, 6 April 2023

Downloads

macOS 11 "Big Sur" or higher
Gnucash-Arm-5.9-1 is now available for download from the GnuCash projects at Sourceforge and Github.
macOS 10.13 "High Sierra" or higher
Gnucash-Intel-5.9-1 is now available for download from the GnuCash projects at Sourceforge and Github.
Alternatives and older versions
Release notes
are included in the disk-image.

For virtually all users it is more appropriate to download the binary rather than to use the procedure described here.

Overview

GnuCash can be built to run more or less natively on macOS -- meaning without X11. Better yet, the build is almost automatic.

This page describes the procedure to build GnuCash with the Quartz environment. You can also use MacPorts: The details are described at MacOS/MacPortsDetail. If you already have MacPorts installed, you should use that procedure, as gtk-osx doesn't work well with a MacPorts installation.

If you want to have a clickable GnuCash.app to put in your Applications folder, this is the solution to use. If you want to be able to easily customize your installation, this is also the solution for you. Don't want all of the extra stuff that MacPorts drags in? Well, this might be a bit better... but GnuCash is notorious for its huge list of dependencies. Want to keep up with the latest work from the Gnome developers? You can set up this solution to get many of its packages directly from source-code-control. That's a double-edged sword, of course, because if a build gets broken, you're pretty well stuck until the developers for that package fix it.

A build will consume about 5 gigabytes of disk space and typically take several hours to run. The initial build, which includes pulling down sources from all dependencies, can take days, depending on how often network errors interrupt the process, and how quickly they are noticed.

This build integrates Gnucash menus with the Mac menubar at the top of the screen. About, Preferences, and Quit are in the "GnuCash" menu (it's named "gnucash-bin" when you run from the command line) in standard Mac style. Standard accelerator keys like Command-Q (quit), Command-S (save), and Command-O (Open) work as well. A patch to Gtk+ allows copy and paste in the register pages.

Support

This procedure depends on the Gnome Gtk-OSX project. Support for that is provided via the gtk-osx-users-list@gnome.org mailing list. Questions, comments, or suggestions about Gnucash should be directed to the appropriate Gnucash mailing list (gnucash-devel for development versions (git master) or gnucash-user for release (3.x, git maint).)

Preliminaries

Read Building Gtk-OSX and scan the jhbuild docs. This procedure is based on both. Note well the warnings about Homebrew, MacPorts, and Fink! Creating a separate user for building and packaging GnuCash is the easiest work-around if you've used any of those systems in your regular userid.

First download gtk-osx-setup.sh by clicking the link or from the command line:

curl -O -L https://gitlab.gnome.org/GNOME/gtk-osx/raw/master/gtk-osx-setup.sh

and run it from the command line. Gtk now requires Python3 to build and Apple provides Python3 only on MacOS 10.15 Catalina, so it will first set up a Python3 virtual environment, then install jhbuild and configure what it needs to run. It will ask if you want to install CPython. You do.

It defaults to installing everything in $HOME/.new_local. If you prefer to install somewhere else, set the environment variables DEVPREFIX and PYTHONUSERBASE to that directory before running gtk-osx-setup.sh. One way to do that is inline with the command, e.g.

DEVPREFIX=$HOME/.jhbuild_root PYTHONUSERBASE=$HOME/.jhbuild_root ./gtk-osx-setup.sh

There are some other directory customizing environment variables, see the list in gtk-osx-setup.sh Default or not, you'll want to add the install location's bin directory to $PATH.

JHBuild is configured to build GnuCash via jhbuildrc-custom. Download this file to your home directory either by clicking the link and moving the downloaded file or from the command line:

curl -O -L https://github.com/gnucash/gnucash-on-osx/raw/master/jhbuildrc-custom

and place it in $HOME/.config--unless you've set something different in $XDG_CONFIG_HOME, in which case put it there.

OS X 10.11 added a security feature called System Integrity Protection or SIP. One "feature" is that it strips linker environment variables (the ones starting with LD_ and DYLD_) from the environment when a "system" program does a fork/exec. For our purposes "system program" means one installed in /bin or /usr/bin, in particular /bin/sh.

The Guile compiler, guiled, is a shell script that as written uses /bin/sh to set the prefix then execs guile to run a compilation script. That fails in the presence of SIP.

One can get around this by disabling SIP, but that's a whole-system change that requires a reboot, and SIP clearly has significant security benefits. Don't do that.

The other workaround is to use a shell that isn't in /bin or /usr/bin. One can just copy /bin/bash to one's user-level bin directory. gtk-osx-setup.sh does that for you, putting it in the install location's bin directory.

The default build location is $HOME/gnucash with subdirectories src, build, and inst for unpacking the sources, building, and installation respectively. You can change that by setting the environment variable PREFIX, e.g.
PREFIX=/opt/gnucash jhbuild bootstrap-gtk-osx
PREFIX=/opt/gnucash jhbuild build
You can make finer-grained changes by editing jhbuildrc-custom.

setup_sdk

With no arguments (the default) setup_sdk() will configure the build for your system. Unless you're building for distribution we recommend that you do this.

If you have Xcode 7 (shipped with OS X 10.9 (Mavericks)) or later you can build for any version from 10.6 on with the included SDK by calling (e.g.)
setup_sdk("10.6", native, ["i386"])
Note, however, that some users have noted linkage problems when doing this.

It is safest to build GnuCash on the earliest macOS version you intend to support.

The GnuCash 2.6.x application bundles were built for Mac OS X 10.5 and later. To do likewise, please see Building for Older Versions of Mac OS X. You'll use
setup_sdk("10.5", "10.5"["i386"])
Notes
  • GnuCash v2.7.x and later use the CMake buildsystem.
  • GnuCash v2.7.x and later requires MacOS X 10.9 ("Mavericks") or later.
  • GnuCash v3.900 and later requires MacOS 10.13 ("High Sierra") or later because it uses C++17 and the attendant standard library.
  • Apple has removed 32-bit runtime support from macOS 10.15, so you'll need to build on an older version of macOS if you want arch='i386'.
  • Apple Silicon is first supported in macOS 11. We have never successfully cross-compiled the Gtk stack so you'll probably need an Apple Silicon Mac to build an Apple Silicon native GnuCash. Note that as of October 2022 WebKitGtk isn't able to find its loadable modules so that reports don't render in GnuCash.
  • PowerPC similarly requires building on a PowerPC machine.

Make any changes by editing jhbuildrc-custom

Building

Once all of the preliminaries are complete, run:

jhbuild bootstrap-gtk-osx
jhbuild build

Building for Development

Please see Development for general guidelines and lots of helpful links.

If you intend to contribute your work to the GnuCash project please subscribe to the gnucash-devel list and coordinate your work with the core developers before starting.

You'll need to work with the appropriate source code repository rather than the release tarball from the procedure so far. Git provides details on our repository and has some help for developers who aren't yet familiar with the git version control system. Open jhbuildrc-custom in your text editor and find the section

#Select which modules to build. The only difference is which gnucash
#module (and all of the dependencies, see above) get built. "
modules = ["meta-gtk-osx-bootstrap", "meta-gnucash-stable"]
#modules = ["meta-gtk-osx-bootstrap", "gnucash-unstable"]
#modules = ["meta-gtk-osx-bootstrap", "gnucash-git"]
#branches["gnucash-git"] = (None, "maint")

and change it to

#Select which modules to build. The only difference is which gnucash
#module (and all of the dependencies, see above) get built. "
#modules = ["meta-gtk-osx-bootstrap", "meta-gnucash-stable"]
#modules = ["meta-gtk-osx-bootstrap", "gnucash-unstable"]
modules = ["meta-gtk-osx-bootstrap", "gnucash-git"]
branches["gnucash-git"] = (None, "maint")
Note the branches line
It will build the current stable branch; to build the development branch, the one leading to the next major release, change maint to master. You may also want to change the prefix directory in the line above that block.

Command-line builds

Once you have your initial build finished you'll start editing sources (they'll be in $HOME/gnucash-stable/src/gnucash-git unless you changed the prefix in jhbuilrc-custom) and you'll want to build and run the unit tests. Start a jhbuild shell and change directory to the build directory:

jhbuild shell
cd %PREFIX/../build/gnucash-git

From there you can run the usual shell commands like cmake and ninja.

Building with Xcode

It's possible to build GnuCash using Apple's Xcode IDE. To make it work first do a regular build as above to get all of the dependencies set up.

Now create a new build directory and ```cd``` to it but do *not* start a jhbuild shell, just export the following environment variables to simplify the cmake invocation:

export PREFIX=/full/path/to/prefix
export PATH=$PATH:$PREFIX/bin
export SRCROOT=$PREFIX/../src

making any required changes. Be sure to make different build directories for the maint and the master branches.

Now create the xcodeproject with cmake:

cmake -G Xcode -D CMAKE_INSTALL_PREFIX=$PREFIX -D GTEST_ROOT=$SRCROOT/googletest $SRCROOT/gnucash-git

If you're building from a tarball you'll need to change the source directory at the end of the line.

For some newer versions of Xcode cmake seems unable to determine the C compiler and tries to use ```ld```. If you encounter errors during Cmake or building saying that `ld` doesn't accept some option try adding

  -D CMAKE_C_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/Xcodetoolchain.default/usr/bin/clang

to the cmake command line. Adjust the path as needed if the Xcode you're using isn't /Applications/Xcode.app.

Notes
  • Because all current branches of GnuCash use C++ features that don't compile on or for earlier versions, GnuCash requires MacOS 10.13 (High Sierra) or later.
  • The dependencies for GnuCash have changed from the 2.x releases. The most significant are that major Linux distributions have dropped support for WebKit1Gtk, so we had to enable support for WebKit2Gtk and that in turn requires that GnuCash switch to Gtk3. We've rewritten several modules in C++ and are using GoogleTest for new unit tests and the Boost Libraries for several language extensions. The register has been fixed to no longer use the obsolete libgnomecanvas and the small part of libgoffice that the CSV importer required has been copied into GnuCash sources.

Documentation

The gnucash documentation is online, of course, but if you want a local copy, you can build the modules gnucash-docs or gnucash-docs-git. Just add whichever one you want to your "modules" argument. If you're using gnucash-docs-git you might also want to select the branch by adding a line

branches["gnucash-docs-git"] = (None, "maint")

setting "maint" or "master" as you prefer.

Debugging

To get a debugging build, add the line setup_debug()

to jhbuildrc-custom. Beware, though, that WebKit doesn't build with debugging enabled. I usually build everything first without debugging enabled, then enable it and rebuild
jhbuild buildone --force --clean
the packages you want to debug. Most of the time you can get by with just glib and gnucash, but depending on what you're working on, you might also want gtk+, gwenhywfar, aqbanking, or libdbi.

Running from the commandline

Now you're ready to try it out:
$PREFIX/bin/gnucash

$PREFIX is the path to where you've built gtk; you can fill it in yourself or use jhbuild shell to set it for you.

Making a Bundle

So far so good, but you don't really want to have to open a Terminal window every time you want to use GnuCash, now do you? Of course not. You want a nice icon in your Applications folder (and maybe in the Dock) to click on when you run GnuCash. Here's how to do this:

N.B. This procedure works only with GnuCash built according to the above instructions.

Clone the bundler, cd into the cloned gtk-mac-bundler directory, and make install
Create a directory somewhere convienient (we'll call it gnucash-bundler from now on), cd to it, and download gnucash.bundle, Info.plist, and gnucash.icns into it.

Look through gnucash.bundle and adjust the paths to match your installation.

Documentation
The bundle includes documentation. If you've built it, great, no problem. You need to have it installed for the Help menu items to work. If you didn't build it and you don't want to, then comment out or remove the lines
  <data dest="${bundle}/Contents/Resources/en.lproj/GnuCash Help/">
    ${prefix}/share/gnome/help/gnucash/C/gnucash-manual
  </data>

  <data dest="${bundle}/Contents/Resources/en.lproj/GnuCash Guide/">
    ${prefix}/share/gnome/help/gnucash/C/gnucash-guide/
  </data>

   <data dest="${bundle}/Contents/Resources/de.lproj/GnuCash Help/">
    ${prefix}/share/gnome/help/gnucash/de_DE/gnucash-manual
  </data>

  <data dest="${bundle}/Contents/Resources/de.lproj/GnuCash Guide/">
    ${prefix}/share/gnome/help/gnucash/de_DE/gnucash-guide/
  </data>

  <data dest="${bundle}/Contents/Resources/it.lproj/GnuCash Help/">
    ${prefix}/share/gnome/help/gnucash/it_IT/gnucash-manual
  </data>

  <data dest="${bundle}/Contents/Resources/it.lproj/GnuCash Guide/">
    ${prefix}/share/gnome/help/gnucash/it_IT/gnucash-guide/
  </data>

  <data dest="${bundle}/Contents/Resources/ja.lproj/GnuCash Guide/">
    ${prefix}/share/gnome/help/gnucash/ja_JP/gnucash-guide/
  <data dest="${bundle}/Contents/Resources/pt.lproj/GnuCash Help/">
    ${prefix}/share/doc/gnucash-docs/pt/gnucash-manual/
  </data>

  <data dest="${bundle}/Contents/Resources/pt.lproj/GnuCash Guide/">
    ${prefix}/share/doc/gnucash-docs/pt/gnucash-guide/
  </data>
  
  <data dest="${bundle}/Contents/Resources/ru.lproj/GnuCash Guide/">
    ${prefix}/share/doc/gnucash-docs/ru/gnucash-guide/
  </data>
To comment out XML code, surround it like so:
<!-- stuff to be commented out -->
Note that comments cannot contain "--".
You're ready to make your bundle:
jhbuild shell                 #to set up the environment for the bundler
export PATH=$PREFIX/bin:$PATH #because jhbuild shell doesn't do this for some reason
gtk-mac-bundler gnucash.bundle
exit                          #quit the jhbuild shell

And your bundle should be ready to go. Try GnuCash.app/Contents/MacOS/GnuCash from the command-line so that you can see any error messages. If that works, try open GnuCash.app. If that works, then you can move GnuCash.app to your Applications folder and it's ready to use.

Bundling Oldstable

To bundle GnuCash version 2.6 and earlier you need gnucash-oldstable.bundle, Info-oldstable.plist instead of the corresponding ones listed above as well as gnucash.launcher. Older versions don't have the Portuguese or Russian Guide translations. Otherwise the procedure is the same.

Bundling from a Git Clone

At present there are two active git branches, 'maint' and 'master'. Both use the primary bundling procedure above.

Making a distribution

  • Make a clean build including the documentation, making sure that you're not building any libraries with debugging. With all of the dependencies, the package is huge enough without it. Make sure that you're using the latest git masters for gtk-mac-bundler and gnucash-on-osx.
  • Edit the version numbers and, if necessary, the copyright dates in Info.plist (or Info-unstable.plist).
  • make sure that $APPLICATION_CERT is set correctly with your Apple Developer Program certificate ID. gtk-mac-bundler uses the value of that environment variable to codesign the app bundle.
  • Make a bundle as described above. Test it.
  • Make a directory named for the version that you're going to distribute and move the new bundle into it.
  • Copy the scriptlet "FinanceQuote Update.app" from the previous version .dmg to the new distribution folder.
  • Copy AUTHORS, DOCUMENTORS, LICENSE, NEWS, and README from the GnuCash source directory to the distribution folder. Rename each file with a ".txt" suffix so that Finder will recognize it and enable QuickLook.
  • Open /Applications/Utilities/Disk Utility.app and select File>New>Disk Image from Folder in the menu. Select your installation directory in the first chooser and name it appropriately in the second (Gnucash-Intel-X.Y-Z.dmg where X.Y is the GnuCash version and Z is the serial number of dmgs for that release, beginning with 1.)
  • codesign the dmg with your Apple Developer Program certificate.
  • Get the SHA-256 hash of the .dmg with
    shasum -a 256 Gnucash-Intel-X.Y-Z.dmg
    
    and paste the result into the SourceForge README.txt, the Github release notes, the news article in gnucash-htdocs, and the release announcement email.
  • Upload both the resulting .dmg to the correct version directory of Gnucash's file manager area on Sourceforge. If this is a stable release, check the "Mac" box on the options panel so that users viewing the project page with a Mac will see the new release in the big green button.
  • Upload the .dmg to the release on Github.
  • Update the appropriate links on the Gnucash webpage.

Accessibility

Gtk has its own accessibility library, atk. It doesn't use or support the Mac's accessibility functions; in particular, one must use the Orca screen reader. This isn't provided in the application bundle as as far as we know there is no ready-made Mac build of it.

Helping Out

If you can work on one of these items, please pitch in! Some are Gnucash issues, some are issues with the Quartz implementation of Gtk, and some are integration issues. Join the gtk-osx-devel mailing list to coordinate your work with others.

Example: Setting up a Development Environment

Platform

  • M1 Mac running macOS Ventura 13.0.1
  • Existing user administrator account with homebrew installed

Goal

  • Create a new macOS user gnucash
  • Install a GnuCash development environment in the gnucash user account
  • Insulated the development environment from the homebrew installation
  • Build GunCash from git repo

Steps

  1. In the existing administrator account, use System Settings > Users & Groups > Add Account... to create the gnucash' administrator account. Then, changing the bash version number as appropriate.
    brew install bash
    cp /opt/homebrew/Cellar/bash/5.2.15/bin/bash /Users/gnucash/Public/Drop\ Box
    chmod +a "user:gnucash deny add_file,search,add_subdirectory,delete_child,readattr,writeattr,writeextattr,readsecurity" /opt/homebrew
    
    • The development environment needs its own copy of bash, but at least in macOS 13, just copying /bin/bash doesn't work
    • The first two commands provide a usable copy of bash to the gnucash user
    • The chmod commands prevent the gnucash user from accessing the homebrew installation
  2. Switch to the gnucash and
    cd $HOME
    curl -O -L https://gitlab.gnome.org/GNOME/gtk-osx/raw/master/gtk-osx-setup.sh
    chmod 755 gtk-osx-setup.sh
    ./gtk-osx-setup.sh
    export PATH="$HOME/.new_local/bin:$PATH"
    cp ~/Public/Drop\ Box/bash $HOME/.new_local/bin
    curl -O -L https://github.com/gnucash/gnucash-on-osx/raw/master/jhbuildrc-custom
    mv jhbuildrc-custom .config
    echo 'branches["gnucash-git"] = (None, "master")' >> .config/jhbuildrc-custom
    sed -i '' -Ee 's/= _modules_stable/= _modules_git/' .config/jhbuildrc-custom
    PREFIX=/Users/gnucash/opt/gnucash jhbuild bootstrap-gtk-osx
    PREFIX=/Users/gnucash/opt/gnucash jhbuild build
    
  3. As of January 2023, the build failed on xmlsec1 due to a missing dependency in gnutls. The build stopped with a menu of several options. The following patched the issue
    # Open another terminal and edit the following package config file
    nano /Users/gnucash/opt/gnucash/inst/lib/pkgconfig/gnutls.pc  # add -lgcrypt to the Libs line & save
    # Back in the original build terminal, select Go to phase "configure" option
    
  4. Install Finance::Quote from source
    PREFIX=/Users/gnucash/opt/gnucash jhbuild shell
    PREFIX=/Users/gnucash/opt/gnucash
    curl -L https://cpanmin.us | perl - App::cpanminus
    export PATH="$PATH:$HOME/perl5/bin"
    cpanm --local-lib=$PREFIX/lib/perl5 local::lib && eval $(perl -I $PREFIX/lib/perl5/lib/perl5 -Mlocal::lib)
    git clone https://github.com/finance-quote/finance-quote.git
    cd finance-quote
    cpanm install Dist::Zilla
    dzil authordeps --missing | cpanm --notest
    dzil listdeps --missing | cpanm --notest
    cpanm install Data::Dumper::Perltidy Smart::Comments
    dzil build
    cpanm Finance-Quote-1.55.tar.gz
    cpanm install JSON::Parse