Start developing LibreOffice! Download the source code, and build on Linux
(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!
Very awesome documentation.
If it could add the procedures required required to get the internationalization features, those that are obtained by installing the deb/rpm language-specific user interface packages, our knowledge would be complete.
(well, there’s also the configuration stuff that is made when installing the libreoffice6.x-debian-menus package, but since it is architecture independent, we guess it could be simply installed on a 32-bit system after compiling LibreOffice.)
Hi, for specific help about building LibreOffice, please ask on the developer mailing list: https://lists.freedesktop.org/mailman/listinfo/libreoffice
Hi thank you for the great HOWTO
there are some minor typos
new-line missing in: `sudo nano /etc/apt/sources.listsudo gedit /etc/apt/sources.list`
and `–with-paralellism=4` should be `–with-parallelism=4`
P.S. maybe it would be also good to update the wiki page https://wiki.documentfoundation.org/Development/BuildingOnLinux or at least link this page
Tanks again
Thanks Artur – I’ve fixed the two things you mentioned 🙂