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
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 not required if building from tarball,
                                                 #               but from any version control system
sudo apt-get install libxml2 libxml++2.6-dev
sudo apt-get install libxslt1.1 libxslt1-dev
sudo apt-get install xsltproc
sudo apt-get install texinfo                     # required for makeinfo

# 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        # > webkit2gtk-3.0
sudo apt-get install libwebkit2gtk-4.0-dev

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. You will have to use the appropriate option switches on the CMake command to incorporate them in the build ( 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. If you require a database backend install the database support

sudo apt-get install libdbi1 libdbi-dev         # > v0.8.3
and one of the following database options:
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 database you want to use.

OFX File importing

sudo apt-get install libofx6 libofx4 libofx-dev


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

sudo apt-get install python3-pytest

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. <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>;
  2. <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). Common locations are:
    1. /usr/local - this location is commonly used for versions distributed with linux distributions and is the default option. If installed here the program will be available to all users on the system. If you use this folder, use it with caution as installing from the distribution will overwrite your build and vice versa. |Filesystem Heirarchy Standard is used by Ubuntu. 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.
  3. <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.

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.

Uninstall Gnucash

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.

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