Start developing LibreOffice! Download the source code, and build on Linux

Please don’t use these instructions in practice – they become obsolete over time. Instead, follow the wiki article for building on Linux as well as the article on Linux Build Dependencies.

(This post was originally written in Hungarian by Adam Kovacs for his blog. Thanks Adam!)

In the previous part of this tutorial series, we showed how to register with Git and Gerrit, to prepare your setup for building LibreOffice and submitting patches.

Today, we describe the steps you need to download and compile the LibreOffice source code on Linux. You can, of course, modify the source code you have downloaded and, if you compile it, you can make sure your changes are working well after the compilation.

In this guide, we are using GNU/Linux distributions (typically Debian and Ubuntu-based distributions) with the apt package management frontend. Those who do not use these distributions need to run apt-get install and similar commands instead.

(Note: an internet connection is required during the compilation, after the build-nocheck command.)


Step 1: Install some required programs and packages

Open a terminal (In Ubuntu, Ctrl+Alt+t) and run this command:

sudo apt-get install git gstreamer1.0-libav libkrb5-dev nasm graphviz ccache

Then enter the password for your username. (If you do not have administrator privileges, you cannot do these steps.)


Step 2: Specify update manager sources

In the file /etc/apt/sources.list, add one of the following lines depending on your distribution:

  • Debian 9:
    deb-src http://http.debian.net/debian/ stretch main
  • Ubuntu 16.04:
    deb-src http://archive.ubuntu.com/ubuntu/ xenial main
  • Ubuntu 18.04:
    deb-src http://archive.ubuntu.com/ubuntu/ bionic main
  • Ubuntu 18.10:
    deb-src http://archive.ubuntu.com/ubuntu/ cosmic main
  • Ubuntu 19.04:
    deb-src http://archive.ubuntu.com/ubuntu/ disco main

You can edit the file using:

sudo nano /etc/apt/sources.list
sudo gedit /etc/apt/sources.list

In Nano, to exit and save: Ctrl+x, then y, then enter. The exact version and codename of the Linux distribution can be found by running the uname -a and lsb_release -a commands.


Step 3: Download available updates and build dependencies

Enter these commands to ensure you get the latest packages, and everything required to build LibreOffice from the source code:

sudo apt-get update
sudo apt-get build-dep libreoffice

Step 4: Download the LibreOffice source code

Create a new directory somewhere for LibreOffice. For example, in your own directory:

cd ~
mkdir libreoffice
cd libreoffice

Go to this directory and run this command there:

git clone git://gerrit.libreoffice.org/core libreoffice

Step 5: Setting up the autogen.input file

Create an autogen.input file in the LibreOffice directory, with this content:

--without-junit
--without-java
--without-help
--without-doxygen
--disable-odk
--enable-debug

You may also need these:

--without-krb5
--without-gssapi

If you still need some settings in autogen.input, you can use the ./autogen.sh –help command to list all possible settings.

Note: if you start compiling and miss any of these options, eg the –enable-debug line, and then add the missing line to autogen.input, the next compilation process will not replace the existing files. If you want the newly inserted line in autogen.input to be valid for the newer compilation, you must delete the results of the old compilation using the make clean command.


Step 6: Build the code

Run these commands:

./autogen.sh
make

If you would like to compile without unit tests (for example, if you don’t want to check that what you have changed in the source code will cause regressions), use the build-nocheck parameter instead:

make build-nocheck

Step 7: Run the new build

When the code is compiled, you can start it from the LibreOffice directory:

./instdir/program/soffice
./instdir/program/soffice --writer
./instdir/program/soffice --calc

At this point, a lot of information is written to the command line while running LibreOffice. We can turn them off like this:

SAL_LOG=-INFO instdir/program/soffice

Now only SAL_DEBUG type values will be written to the command line (if they are already placed in the code somewhere).

If you just want to convert a file (for example, to fix export errors), you can do so. The converted file is then created in the LibreOffice directory (it is therefore advisable not to place the files to be converted in the LibreOffice directory, to avoid confusing them with the files that have already been converted). For instance:

SAL_LOG=-INFO instdir/program/soffice --convert-to docx ../chart_borderline.docx

Additional information

When the compilation is finished, and we modify the contents of one of the source files, we will start the compilation again. But this will not compile the entire codebase from scratch (unless we run the make clean command), but it only compiles the files we modified, which is a significant time saving.

If we forget to include a setting in autogen.input, but the compilation has already been done, then it is not enough to add the setting and start the compilation again – we also need to run make clean before.

For example, if we compiled without –enable-debug, add –enable-debug to the autogen.input file, then run make clean, followed by make or make build-nocheck.

You can also compile specific modules of LibreOffice:

make sw

Or:

make sw.build

These are the names of the modules:

  • sw: Writer (formerly StarWriter)
  • sc: the spreadsheet (Calc)
  • sd: Impress and Draw
  • dbaccess: database manager (Base)
  • starmath: formula editor
  • oox: source code files for importing and exporting Office Open XML files (docx, xlsx, pptx, …)
  • chart2: source code files for managing charts

For more modules, see here.


Keep watching the blog for more guides and tips for LibreOffice development!

Comments

  1. By Escuelas Linux

  2. By Artur Neumann

    • By Mike Saunders