MacOS/Quartz

From GnuCash
Revision as of 02:34, 5 May 2008 by Pponson (talk | contribs)
Jump to: navigation, search

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.

Overview

The sequence of steps here 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.


Before you begin, there are a 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

Update January 2008:

The instructions for building gtk for OSX are here: http://developer.imendio.com/projects/gtk-macosx/build-instructions

You'll need Subversion if you don't already have it; if you have Leopard, it's already there.

Note that the default install location for jhbuild is /opt/gtk, which is OK unless you have MacPorts. You can override it in ~/.jhbuildrc-custom. If you do, replace /opt/gtk with whatever you choose in the --prefix= arguments below. If you don't, make sure that you have a /opt directory and that you have write permission for it.

I encountered a problem with jhbuild making gmp and guile; my solution is here: http://developer.imendio.com/node/167 It appears, though, that they've been removed from jhbuild, so you shouldn't have to worry about it.

Be sure to do the rest of your building inside the shell created by jhbuild shell

Otherwise you'll need to set a bunch of environment variables at various stages.

The old instructions, with gtk-osx-build. There's a note about this at the bottom of the build-instructions page: It's deprecated, but they have a link to further instructions.

  1. Install git and subversion from MacPorts or Fink.
  2. 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.
  3. Follow the instructions to build gtk+ at http://developer.imendio.com/projects/gtk-macosx/build-instructions:
    1. First do the "bootstrap"
    2. Then the "core"
    3. And then build all of the modules in the "Extra:" list printed when you execute gtk-osx-build help, one by one in the order on that list.
  4. Execute gtx-osx-build shell to get the proper environment, and execute all further commands in the resulting shell.

GnuCash's many other requirements

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. tar -zxvf <tarball filename>, cd into the top level directory extracted, execute the configure command, and then execute make and then make install. The "standard configure" command listed in many cases below is ./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-xlib (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.

(Jan 2008) As built by jhbuild, pango is missing freetype (libpangoft2), which is needed by libgnomecanvas. It's present in /usr/X11 in at least Tiger and Leopard (if you installed X11), or you can build it over (which is probably easier).

To build it from within jhbuild, add

modules = [ 'meta-gtk-osx-bootstrap', 'meta-gtk-osx-core' , 'meta-gtk-osx-freetype' ]

to your .jhbuildrc-custom before running jhbuild build.

To use the installed version, issue

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/X11/lib/pkgconfig

from inside the jhbuild shell and rebuild pango (i.e., cd to srcdir/pango and do make && make install).

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.

  1. readline, ftp://ftp.gnu.org/pub/gnu/readline, ./configure --prefix=/opt/gtk. 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.
  2. guile 1.6.8, ftp://ftp.gnu.org/pub/gnu/guile, standard configure. Guile 1.8 may be 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 (map (lambda (foo) (bar))), which is perfectly valid Scheme -- but guile 1.8 doesn't recognize map as a function name. To be safe, go to the source directory where jhbuild built guile (if it did) and run make uninstall before installing guile-1.6.8
  3. 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:
    ln -s <slib directory> /opt/gtk/share/guile/1.6
    mkdir /opt/gtk/share/guile/site
    

    If you prefer, you can skip the symbolic link and instead export SCHEME_LIBRARY_PATH=<slib directory>.
    Start guile and run the following lisp commands:

    $guile
    guile> (use-modules (ice-9 slib))
    guile> (require 'new-catalog)
    guile> (quit)
    
    Slib is now ready to use.
  4. libIDL, GNOME, standard configure
  5. ORBit2, GNOME, standard configure
  6. GConf, GNOME, ./configure --prefix=/opt/gtk --enable-static --enable-shared --disable-scrollkeeper --disable-xlib (note the --enable-static here)
  7. OpenSP, http://sourceforge.net/projects/openjade, (Don't bother with OpenJade, it's NOT required and can be a pain to build)./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-doc-build
  8. libofx, http://libofx.sourceforge.net, ./configure --prefix=/opt/gtk --disable-static --enable-shared --with-opensp-includes=/opt/gtk/include/OpenSP --with-opensp-libs=/opt/gtk/lib/
  9. popt, http://rpm.net.in/mirror/rpm-4.4.x, ./configure --prefix=/opt/gtk --disable-static --enable-shared
  10. audiofile, GNOME, ./configure --prefix=/opt/gtk --disable-static --enable-shared
  11. esound, GNOME, ./configure --prefix=/opt/gtk --disable-static --enable-shared
  12. dbus and dbus-glib, http://www.freedesktop.org/wiki/Software/dbus/, for each one: ./configure --prefix=/opt/gtk --disable-static --enable-shared
  13. libart_lgpl, GNOME, standard configure (Jan 2008)
  14. libglade, GNOME, standard configure (Jan 2008)
  15. libgnomecanvas, GNOME, standard configure (Jan 2008)
  16. gnome-mime-data, gnome-vfs, libbonobo, libgnome, libbonoboui, from GNOME, standard configure for each one.
  17. libgpg-error and libgcrypt, http://www.gnupg.org/download/index.en.html, standard configure. (Jan 2008)
  18. libtasn1, http://josefsson.org/gnutls/releases/libtasn1/, standard configure (Jan 2008)
  19. gnome-keyring, GNOME, standard configure
  20. Download and extract libgnomeui from GNOME
    Under 2.18 the following was necessary:
    In the libgnomeui directory: Comment out the following section of the configure script at line 23836:
    #    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
    

    comment out line 845 of libgnomeui/gnome-ui-init.c:

            /* XUngrabServer (GDK_DISPLAY ()); */
    

    But it wasn't for 2.21.
    ./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-xlib --without-x, and make and make install.

  21. libgnomecups, SOURCES/libgnomecups, standard configure
  22. Download and extract libgnomeprint-2.18.0 from GNOME
    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 LIBM= in 2.18.3.
      LIBM=" "
    

    And then ./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-xlib --disable-gtk-doc.
    Next you need to change line 945 of libgnomeprint/Makefile from:

    	$(FLEX_PATH) -P_gnome_print_filter_parse_yy $^
    

    to

    	$(FLEX_PATH) -P_gnome_print_filter_parse_yy parse.l
    
    and finally do make and make install.
  23. libgsf, SOURCES/libgsf, standard configure
  24. pcre, ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/, ./configure --prefix=/opt/gtk --disable-static --enable-shared --enable-utf8
  25. libgoffice, SOURCES/goffice, standard configure
  26. icon-naming-utils, http://tango.freedesktop.org/Tango_Icon_Library (Jan 2008)
  27. gnome-icon-theme, SOURCES/gnome-icon-theme, standard configure (Jan 2008)
  28. Download and extract gtkhtml from SOURCES/gtkhtml
    Then, execute the configure command GAIL_CFLAGS=" " GAIL_LIBS=" " ./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-xlib; The following was required for 3.15 but not for 3.17.90:
    • Delete line 260 of Makefile:
      	a11y					\
      
    • Delete ../a11y/gtkhtml-a11y.la from line 66 of src/Makefile, yielding
      	$(am__DEPENDENCIES_1) \
      
    • Delete ../a11y/gtkhtml-a11y.la from line 569 of src/Makefile, yielding
      libgtkhtml_3_14_la_LIBADD = $(GTKHTML_LIBS) $(GAIL_LIBS) $(REGEX_LIBS)
      
    • Comment out line 3170 of src/gtkhtml.c:
      /*	gtk_html_accessibility_init ();  */
      
      and finally make and make install.

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.

GnuCash

Finally you're ready for GnuCash itself: Downloaded and extract gnucash from gnucash.org.

Edit configure and replace:

-for ac_header in X11/Xlib.h glob.h
+for ac_header in glob.h

Where this line is will depend on what version of gnucash you have. The original version of this page suggested defining the environment variable

   SCHEME_LIBRARY_PATH=/opt/gtk/share/guile/1.6/slib

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. For building gnucash 2.2.3 under Leopard, I made the following changes before building:

  1. In src/engine/SplitP.h,
    @@ -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);
    
    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)
  2. In src/bin/gnucash.in,
    @@ -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}"
    
    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.

Now run configure:

 ./configure --prefix=/opt/gtk --disable-static --enable-shared --disable-scrollkeeper --disable-gtk-docs --enable-ofx --disable-xlib

followed by make && make install

The original version of this page (for gnucash 2.1.1 and Tiger) had the following procedure after installing:

   mkdir /opt/gtk/libextra
   cd /opt/gtk/libextra
   ln -s ../lib/libgnc* ../lib/libguile* .

Edit /opt/gtk/bin/gnucash as follows: replace line 20, which is:

DYLD_LIBRARY_PATH="${EXTRA_LIBS}:${DYLD_LIBRARY_PATH}"

with the following two lines:

DYLD_LIBRARY_PATH="/opt/gtk/lib/gnucash:/opt/gtk/libextra:${DYLD_LIBRARY_PATH}"
SCHEME_LIBRARY_PATH=/opt/gtk/share/guile/1.6/slib
and insert the following line:
export SCHEME_LIBRARY_PATH
between:
export DYLD_LIBRARY_PATH
and:
exec gnucash-bin "$@"


Now cross your fingers and try running it -- you can execute gnucash 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.

As of January 2008, the splash screen now appears and the progress bar for the file load works.

Good luck!