Compile LibreOffice from Source on Ubuntu

This guide provides a straightforward, step-by-step walkthrough for compiling LibreOffice from its source code on an Ubuntu system. You will learn how to prepare your system, install the necessary dependencies, clone the official Git repository, configure the build parameters, and execute the compilation process to produce a functional local build of LibreOffice.

1. Prerequisites and System Requirements

Compiling LibreOffice is resource-intensive. Ensure your machine meets the following minimum recommendations: * Disk Space: At least 30 GB of free space (50 GB recommended if building with debug symbols). * RAM: At least 8 GB of RAM (16 GB or more recommended to avoid out-of-memory errors during multi-core compilation). * CPU: Multi-core processor (quad-core or higher recommended).

2. Enable Source Repositories and Install Dependencies

Ubuntu provides a simple way to install most required build dependencies via APT.

  1. Enable the source code repositories by editing /etc/apt/sources.list or using the Software & Updates GUI to check “Source code”. Alternatively, run:

    sudo sed -i '/^#\s*deb-src /s/^#\s*//' /etc/apt/sources.list
  2. Update your package lists:

    sudo apt update
  3. Install the primary build dependencies and compilation tools:

    sudo apt build-dep libreoffice
    sudo apt install git ccache default-jdk libcups2-dev libfontconfig1-dev libgl1-mesa-dev

3. Clone the LibreOffice Repository

Fetch the latest source code from the official Freedesktop Git repository:

git clone git://anongit.freedesktop.org/libreoffice/core libreoffice
cd libreoffice

4. Configure the Build Environment

Run the autogen.sh script to check your system for required libraries and generate the configuration files.

You can run it with default settings:

./autogen.sh

To speed up the compilation or tailor the build, you can pass optional flags:

./autogen.sh --without-java --enable-release-build

If autogen.sh reports missing packages, install the specified packages using sudo apt install <package-name> and re-run ./autogen.sh until the configuration completes successfully.

5. Build LibreOffice

Start the build process using the make command. LibreOffice automatically detects the number of available CPU cores and compiles in parallel:

make

Note: Depending on your hardware performance, the initial compilation can take anywhere from 30 minutes to several hours.

6. Run the Compiled Build

Once the compilation finishes without errors, the functional binaries are located in the instdir directory. Launch your freshly built LibreOffice suite using the following command:

instdir/program/soffice