From GnuCash
Jump to: navigation, search

Build Gnucash v3 from Source on Ubuntu 16.04 (also Ubuntu versions to 18.04 Linux Mint 18.3 and Debian)

To build and run Gnucash 3.x from source you may need to install following packages and development headers by running the following commands in a shell (terminal window):

Build Tools

sudo apt-get install build-essential git
sudo apt-get install cmake

Obtain the GnuCash Sources

Setup GoogleTest

GnuCash Dependencies

Up to date information on the dependencies may be obtained from:

Only the build headers are generally required to build GnuCash however the libraries will be required to run it. Many are often installed in most Linux distributions. You can check whether the required libraries and/or headers are installed by listing the installed packages. Run:

dpkg -l | grep <package-name>
in a shell where
is the name of a package or an identifying substring of the package name.

In Ubuntu and derivates install from the repositories by running the following commands in a shell.

sudo apt-get install libtool libltdl-dev
sudo apt-get install libglib2.0 libglib2.0-dev   #glib2 > v2.40.0
sudo apt-get install icu-devtools libicu-dev
sudo apt-get install libboost-all-dev            # boost > 1.50.0  - requires locale and regex built with ICU support
sudo apt-get install guile-2.0 guile-2.0-dev     # guile >=2.0.0
sudo apt-get install swig2.0                     # swig  >2.0.10 (use swig3.0 on Ubuntu 18.04 and Linux Mint 19) not required if building from tarball,
                                                 # but required if building from a git clone
sudo apt-get install libxml2 libxml++2.6-dev libxml2-utils
sudo apt-get install libxslt1.1 libxslt1-dev
sudo apt-get install xsltproc
sudo apt-get install texinfo                     # required for makeinfo
sudo apt-get install libsecret-1-0

# Only use the next 2 lines if needed after reading above Instructions for Installing Google Test to Build Gnucash
# libgtest-dev + google-mock in Ubuntu 16.04 is 1.7.0
sudo apt-get install libgtest-dev                # >=1.7.0
sudo apt-get install google-mock                 # 1.8.0 installs googlemock in subdirectory of gtest

sudo apt-get install gtk+3.0
sudo apt-get install libgtk-3-dev
sudo apt-get install libwebkit2gtk-4.0-37 libwebkit2gtk-4.0-dev  # > webkit2gtk-3.0

Note: If installing for Ubuntu 18.04 swig2.0 is not available from the apt repository, however swig3.0 is available and can be used by substituting swig3.0 for swig2.0 in the install command above. swig3.0 can also be installed on Ubuntu 16.04 and Linux Mint.

Note: The commands above used here the apt-get format. Other package managers or higher level interfaces (e.g dpkg, apt, aptitude, Synaptic, Ubuntu Software Centre or Software Managerin Linux Mint) may be used by substituting in the appropriate command syntax. See [package management] for further information.

Some of the optional dependency packages are also available from | SourceForge- Gnucash Dependencies. See the README and/or INSTALL files in each package for installation instructions.

Option Dependencies

The following are the dependencies of optional additions to GnuCash and should be incorporated if you need those specific options. These options are generally included by the default options for the cmake switches in a standard build with no switches specified with the exception of the Python extensions. You should generally include these libraries unless you specifically do not want the option. You will have to use the appropriate option switches on the cmake command to change the default build options. See( build options).

Database Backend

GnuCash uses an xml file as its default storage. A database backend is available as an option if required. For users with minimal database administration experience, the sqlite3 option is likely to be easier to setup and administer. The database support is included by default but can be disabled if not required with a cmake option switch.

sudo apt-get install libdbi1 libdbi-dev         # > v0.8.3
and at least one of the following database backends:
sudo apt-get install libdbd-pgsql                # PostgreSQL database
sudo apt-get install libdbd-mysql                # MySQL database
sudo apt-get install libdbd-sqlite3              # Sqlite database

depending upon which databases you want to use.

OFX File importing

OFX file import support is normally built by default. These libraries should be included unless you do not want this option. Use the cmake option switch to disable it during the build if you do not require it.

sudo apt-get install libofx-dev   # This  will automatically install the corresponding libofx<n> package as well, i.e libofx6 on 16.04, libofx7 on 18.04)


Aqbanking support is normally built by default in GnuCash. These libraries should be included unless you do not require this option. Use the appropriate cmake option switch to disable it if not required.

sudo apt-get install aqbanking-tools libaqbanking-dev   # > v4.0.0
sudo apt-get install gwenhywfar-tools libgwenhywfar60 libgwenhywfar60-dev
sudo apt-get install ktoblzcheck libktoblzcheck1-dev

Python Support

Python support is not included by default in GnuCash. If required you should install these libraries and use the appropriate cmake option switch during the build.

sudo apt-get install python3-pytest

Uninstall GnuCash

It is a good idea to uninstall any previous versions of GnuCash that you may have installed in the location into which you intend to install your new build. This will remove any unused files and may prevent intererence by anypreviously installed GnuCash files.

If you built GnuCash and you have retained the build directory on your system, use the following command issued in a shell opened in the build directory from which you installed GnuCash:

make uninstall             # prefix with sudo if you installed in /usr/local or /opt.

If you no longer have the build directory you installed from or your previous version was a distribution version see Uninstall Gnucash Ubuntu for other options.

Build Gnucash

Best practice with CMake requires use of a separate build directory. This may be placed either inside the top level source directory, at the same level in the parent directory for the top level source directory (gnucash-3.<x>) or at any other suitable location within your home directory. Note: Some problems have been experienced with some libraries (not currently used in GnuCash but used in the documentation) when the build directory is placed within the top level "gnucash" or gnucash-3.x" source directory.

The cmake command syntax is cmake -D<install-target> <build-options> <build-source>. For further information see Cmake Build Directory Structure Options and Addressing.

  1. <install-target> is the location to which you wish to install gnucash on your system (this is actually a build option but has been specified separately for clarity). The format is CMAKE_INSTALL_PREFIX=<value> where <value> is a path specification to an install location. Common locations are:
    1. /usr/local - this location is commonly used for installing locally built versions of applications that should be available to all users on the system. It will not be overwritten by a version installed using the distributions package manager. If using this location, precede make install with sudo for admin privileges.
    2. /opt - this location is frequently used for user built software. (see comment for /usr/local regarding use of this location).
    3. $HOME/.local - in your home directory. Requires adding $HOME/.local/bin to $PATH environment variable. Use export PATH=$PATH:$HOME/.local/bin at a shell prompt to set PATH for that shell. To make the changes to PATH permanent, you can add this command to the file .profile or the file .bashrc in your home directory. $HOME is usually defined by default for Ubuntu, Linux Mint as /home/<user> where <user> is the logged in user name. If not enter export HOME=/home/<user> in the shell or add this command to /home/<user>/.profile (or .bashrc) to make permanent.
  2. <build-options> are 0 or more CMake option choices, blank separated, of the form -D <option> =<value> where <option> is one of the GnuCash build options for CMake.
  3. <build-source> is either an absolute reference to the top level gnucash-3.<x> directory or a relative reference to it from the build folder, whereever that is located. For the case illustrated below, <build-source> = ../gnucash-3.<x>;

Open a shell and change directory to the directory into which you extracted the GnuCash sources (gnucash-3.x) or cloned the github repository (gnucash), i.e. the parent directory of gnucash-3.<x> or gnucash.

mkdir build-gnucash-3.<x>           # create the build directory - Note: Named to identify the source since it is not within the source directory.
cd build-gnucash-3.<x>              # change into the build directory
# add other cmake option switches after the first before the relative reference to the build source as required. As shownhis will install in the .local directory in /home/<user>.
cmake -D CMAKE_INSTALL_PREFIX=$HOME/.local ../gnucash-3.<x>       
make install                # prefix with sudo if you do install to /usr/local or /opt as admin privileges are required.

The following examples are from a successful build (Linux Mint 19 Tara -Ubuntu 18.04). Output may differ slightly with different OSes and versions. Sample cmake output for a successful configuration:

source file in       $Home/Applications/gnucash-3.2
build file in        $HOME/Applications/gnucash-3.2/build
install location     /usr/local
$cd $HOME/Applications/gnucash-3.2/build
-- Using guile-2.0.x
-- Using guile SRFI-64
-- Checking for module 'gwengui-gtk3'
--   No package 'gwengui-gtk3' found
-- Checking for GTEST
-- Checking for GMOCK
-- Performing Test have_mod_mask
-- Performing Test have_mod_mask - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/david/Applications/gnucash-3.2/build

$make output to terminal here


For information on directories where configuration informnation for GnuCash is located for Linux, Windows and MacOSX follow the link in the heading.

Gnucash Documentation

To have the documentation locally accessible from the GnuCash Help menu, see Documentation_Update_Instructions for details. Here is a small summary:

sudo apt-get install libxml2-utils
cd <path to the gnucash-docs directory>
mkdir build-docs-autotools
cd build-docs-autotools
../configure --prefix=<docs-target>
make install

Now you start GnuCash providing it with the information where to find the docs:

XDG_DATA_DIRS="<docs-target>/share:$XDG_DATA_DIRS" <target(from above)>/bin/gnucash