Difference between revisions of "Building On Linux"

From GnuCash
Jump to: navigation, search
(Setting up to Build GNuCash on Linux)
Line 14: Line 14:
 
#[[Installing_Dependencies | Installing Dependencies]].
 
#[[Installing_Dependencies | Installing Dependencies]].
  
== Configuring your Build ==
+
== Building and Installing the GnuCash Program ==
== Building the GnuCash Program ==
+
It is generally 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 any previously installed GnuCash files and libraries. See [[#Uninstalling_Gnucash]].
== Installing the Built Program ==
+
 
 +
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 as 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 Addressing | Cmake Build Directory Structure Options and Addressing.]]
 +
# '''<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:
 +
## '''/usr/local'''      - this location is commonly used for installing locally built versions of applications that should be available to all users on the system.  Some distributions may install the version of their software to this location instead of to /usr. If using this location, precede '''make install''' with '''sudo''' for admin privileges.
 +
## '''/opt'''            - this location is frequently used for user built software. (see comment for /usr/local regarding use of this location).
 +
## '''$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.
 +
# '''<build-options>''' are 0 or more CMake option choices, blank separated, of the form -D <option> =<value> where <option> is one of the  GnuCash[[Gnucash Build Options | build options]] for CMake.
 +
# '''<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.
 +
<SyntaxHighlight lang="sh">
 +
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
 +
make install                # prefix with sudo if you do install to /usr/local or /opt as admin privileges are required.
 +
</SyntaxHighlight>
 +
 
 
== Running GnuCash ==
 
== Running GnuCash ==
 
== Uninstalling GnuCash ==
 
== Uninstalling GnuCash ==
 +
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:
 +
<SyntaxHighlight lang="sh">
 +
make uninstall            # prefix with sudo if you installed in system locations like /usr/local or /opt.
 +
</SyntaxHighlight>
 +
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.
 
==Distribution Specific Issues ==
 
==Distribution Specific Issues ==
 
===Linux Mint 19/Ubuntu18.04
 
===Linux Mint 19/Ubuntu18.04
 
On Linux Mint 19/Ubuntu 18.04 Google Test can be installed from the Software Manager
 
On Linux Mint 19/Ubuntu 18.04 Google Test can be installed from the Software Manager

Revision as of 08:43, 25 September 2018

Building GnuCash on Linux from the Source Code

This page and the linked pages contains generic instructions for building on many Linux distributions. Some Linux distributions may vary in specific details like:

  • the package manager they use to install software from the distribution repositories;
  • the names of libraries and header files for compiling libraries in their repositories;
  • locations in which libraries and programs are commonly installed.

Where information on these differences is known it will be listed in distribution specific sections for some common distributions in use in the GnuCash community. This information can be used to translate these instructions to those specific distributions. In most cases translation generally involves substituting a package managers name for "apt" which is used in the following and the names of the library files in the repositories of the distributions. The distribution specific sections will contain some information on how you might determine library names on that distribution. The instructions in the following are usually directly applicable directly to Debian/Ubuntu distributions and direct derivatives (although not necessarily all of them). Where such information is not available here, you may need to consult the distribution documentation for the required information. Please feel free to add distribution specific information relevant to these instructions for distribuitions that are not currently listed.

Most distributions have a package manager tool (some have several) that is for installing and removing software from the shell. Many also include a GUI software manager interface which can serve the same function. These are used to install the build tools and dependencies (libraries and development headers) needed to build GnuCash. Some package managers will have a different syntax from that shown for apt (e.g option switches instead of a <command> <target>. If you are not familiar with the command syntax consult the man pages for the package manager on your system to translate the commands from the apt syntax. A table of the names of the package manager front ends on some Linux systems is given here. In some cases the libraries may have slightly different names from those given here as may the development header files. Your package manager will have a command for searching its software repository. Again consultyour distributions documentation. Instructions for installing software will be given here using apt which is the preferred front end on Ubuntu based system.

Setting up to Build GNuCash on Linux

To build GnuCash on a Linux system you will first have to have completed the following steps. Detailed instructios for each step are given on the linked pages.

  1. Installing the Build Tools;
  2. Getting the GnuCash sources;
  3. Installing Google Test;
  4. Installing Dependencies.

Building and Installing the GnuCash Program

It is generally 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 any previously installed GnuCash files and libraries. See #Uninstalling_Gnucash.

Best practice with CMake requires use of a separate build directory. This may be placed either:

  1. inside the top level source directory,
  2. at the same level in the parent directory as the top level source directory (gnucash-3.<x>) or
  3. 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. Some distributions may install the version of their software to this location instead of to /usr. 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
make install                # prefix with sudo if you do install to /usr/local or /opt as admin privileges are required.

Running GnuCash

Uninstalling GnuCash

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 system locations like /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.

Distribution Specific Issues

===Linux Mint 19/Ubuntu18.04 On Linux Mint 19/Ubuntu 18.04 Google Test can be installed from the Software Manager