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!

Announcing a new website: What can I do for LibreOffice!

Here at The Document Foundation, we’re always encouraging people to join our projects and community. Contributing to a well-known open source project is a great way to meet new people, have fun, build up skills and experience, and help to make the world a better place!

However, large FOSS projects can be daunting too. Our Get involved page aims to make the on-boarding process for newcomers easier, by breaking the process down into smaller steps, and we plan other improvements to that page.

But today, we’re announcing a new website targeted at potential contributors: What can I do for LibreOffice. This is inspired by What can I do for Mozilla, and much of the work was done by our awesome contributors from Albania – read their blog post about it here.

In “What can I do for LibreOffice”, visitors are asked what they’re interested in, and pointed to resources to get started. So instead of large web pages with walls of text, visitors can click around and find something that catches their eyes. The website source is on Gerrit if anyone has suggestions for updates or additions, and the site can be translated too.

Anyway, click here to check it out – and let us know what you think!

LibreOffice 6.3 on Linux, a statement

Following the availability of LibreOffice 6.3 Beta, there have been speculations about 32-bit compatibility based on a the missing 32-bit binaries for Linux.

We have prepared a short and a long statement to clarify the situation.

TL;DR

  1. The Document Foundation is ending the provision of 32-bit binaries, and NOT 32-bit compatibility as a whole.

  2. Distro vendors or anyone running a more current 32-bit Linux system can still create 32-bit versions of LibreOffice, as developers have not in any way removed 32-bit compatibility from the source code. Additionally, we are not removing any 32-bit builds that were previously created.

  3. Most Linux users are sourcing LibreOffice from their distro repositories, which are usually compiled against the distro’s version of the various external libraries. We do not anticipate distros dropping 32-bit LibreOffice packages.

  4. TDF does not anticipate the same decision happening for LibreOffice 32-bit binaries for Windows any time soon.

LONG

  1. During the last two years, the number of downloads of the 32-bit Linux distribution-neutral binaries provided by The Document Foundation have decreased to a very low number. Today, the time needed to compile, test, maintain and distribute those binaries is not worth the effort, based on current download numbers. So, TDF is ending the provision of 32-bit binaries, and NOT 32-bit compatibility as a whole.

  2. Today, 32-bit packages are very much the domain of specific Linux distros rather than a general user need. So, we are leaving them to distros, who will upstream fixes. Indeed, distro vendors or anyone running a more current 32-bit Linux system can still create 32-bit versions of LibreOffice, as developers have not in any way removed 32-bit compatibility from the source code. Additionally, TDF is not removing any 32-bit binaries that were previously created.

  3. Most Linux users are sourcing LibreOffice from their distro repositories, which are usually compiled against the distro’s version of the various external libraries. LibreOffice by itself ships a number of external components to avoid dependencies, while distros link against the versions of those components which are part of the distro anyway. TDF does not anticipate distros dropping 32-bit LibreOffice packages.

  4. The Document Foundation does not anticipate the same decision happening for Windows 32-bit binaries any time soon. Of course, if downloads of Windows 32-bit binaries from TDF mirror servers drop to the same very low number as Linux 32-bit packages, TDF will reconsider the situation.

Next C++ workshop: MSTs and Graph Implementations, 6 June at 18:00 UTC

Learn C++ features with the help of LibreOffice developers! We’re running regular workshops which focus on a specific topic, and are accompanied by a real-time IRC meeting. For the next one, the topic is MSTs and Graph Implementations. Start by watching this presentation:

Please confirm that you want to play a YouTube video. By accepting, you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

And check out the suggested EasyHacks.

Then join us for a discussion via our #libreoffice-dev IRC channel. You can ask experienced LibreOffice developers questions, and learn more about the language. We look forward to meeting you!

Month of LibreOffice, May 2019: The winners!

At the beginning of May, we started a new Month of LibreOffice, celebrating contributions all across the project. Well, May has come to a close now, so how many people got sticker packs throughout the month? Check it out…

It’s the best Month of LibreOffice ever, beating the previous one by 10! So congratulations to everyone who won a sticker pack – and thanks so much for your contributions. It’s great to see such a passionate community helping to bring powerful, free and open source software to the world.

Now, how can you claim your sticker pack? Click the 355 above, and if you see your name (or username) on that page, get in touch! Email mike.saunders@documentfoundation.org with your name (or username) from the wiki page so that we can check, along with your postal address, and we’ll send you these:

(Note: your address will only be used to post the stickers, and will be deleted immediately afterwards.) If you contributed to the project in May but you’re not on the wiki page, please let us know so that we can add you!

But there is one more thing…

For this Month of LibreOffice, we have a special bonus: 12 sticker winners have also been selected at random to get an exclusive LibreOffice glass mug! It looks like this:

And here are the winners:

  • Dave Barton
  • DaeHyun Sung
  • ve3oat
  • @muvon (Mastodon)
  • Platterbaff
  • Oliver Brinzing
  • Adam Kovacs
  • Mihail Balabanov
  • @RonneyGey (Mastodon)
  • Olexandr Pylypchuk
  • Seda Stamboltsyan
  • Durgapriyanka

Congratulations to you all! We’ll be in touch with details for claiming your mugs…

So, the Month of LibreOffice has finished – but we plan to do another one in November, with another opportunity to get cool merchandise! And, of course, you can join our friendly community at any time and contribute back to the project. Cheers!

Start developing LibreOffice! Registering with Git and Gerrit, and local settings

Please don’t use these instructions in practice – they become obsolete over time. Instead, follow the wiki article on gerrit.

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

Want to start hacking on the LibreOffice source code? Start here! Follow the steps in this guide to enable automatic verification, so that you can submit your changes to the LibreOffice Git repository. If your code patches are accepted by other developers in the project, they will be added to the code for the next version, and then everyone in the world who uses LibreOffice will benefit from them.

This description does not include the submission (commit and push) of the patch, but only creates the preconditions for it.

If you get stuck at one of the points, reading these links can help:


Step 1 – Download the code

Create a directory (folder) for LibreOffice somewhere on your computer. At the command prompt (in a terminal in Linux, or eg Cygwin in Windows), access this folder and run the following command:

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

Some notes:

  • You do not have to run “git init” after “git clone”
  • Just run the “git clone” command for the steps listed here; you don’t have to start autogen.sh and the compilation, unless you want to test your code modifications

Step 2 – Registering with Git

Git is a distributed version-control system for tracking changes in source code during software development. Register at: https://github.com.


Step 3 – Registering with Gerrit

What is a Gerrit? It complements Git. You can view patch files, messages, the results of the automatic tests of modifications, comments from senior programmers on the web interface, and whether your submitted patch has been accepted.

Register at: https://gerrit.libreoffice.org.

Fill in the following: username (no spaces and accents, example: adamkovacs), name (example: Adam Kovacs), email (example: something@valami.com). These can be found in the “Profile” and “Contact information” menu items.


Step 4 – Create SSH key

Linux:

ssh-keygen -C 'you@email.com'

Windows:

ssh-keygen.exe -C 'you@email.com'

After you run the command, you should also enter a password if you still have access to the files generated by the command, for example to commit code in your name. (The password will be required for “./logerrit submit master”, for example.)


Step 5 – Copying SSH public key into Gerrit

Copy the full contents of the id_rsa.pub file in the ~/.ssh/ folder into Gerrit by selecting SSH Public Keys.

In the ~/.ssh/ folder, create a file named “config” with this content:

Host logerrit gerrit.libreoffice.org
    IdentityFile ~/.ssh/id_rsa
    User gerritesfelhasznalonev
    Port 29418
    HostName gerrit.libreoffice.org

(It may be that port 22 (SSH( is disabled at some workplaces or public networks.)

You may need to run the following command in ~/.ssh/:

chmod 600 config

This sets a write and read (4 + 2) permission for your own username, and no permissions (0) for your group and the outside world.


Step 6 – Local Git repository

Set up your local Git repository with the username and email address as set in Gerrit, with the following commands after entering your LibreOffice directory:

git config --global user.name "Sajat Nev"
git config --global user.email "sajat@email.cim"

Use the “git config –list command” to retrieve the current settings. If they don’t include a name and email address, we haven’t set up anything yet. But with the “git config user.name” and “git config user.email” commands, you can more clearly verify this.

The file named config in the .git directory that’s inside the LibreOffice directory should look like this:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
[remote "origin"]
    url = ssh://felhasznalonev@gerrit.libreoffice.org:29418/core
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[user]
    name = Gerriten Megadott Nev
    email = gerriten_megadott_email_cim
[submodule "dictionaries"]
    active = true
    url = ssh://felhasznalonev@gerrit.libreoffice.org:29418/dictionaries
    ignore = all
[submodule "helpcontent2"]
    active = true
    url = ssh://felhasznalonev@gerrit.libreoffice.org:29418/help
    ignore = all
[submodule "translations"]
    active = true
    url = ssh://felhasznalonev@gerrit.libreoffice.org:29418/translations
    ignore = all

The above commands may not have changed anything in this file, in which case you can manually overwrite the file, or enter the directory containing the file and issue this command:

chmod 600 config

Then try the previous “git config” commands again.

You might want to change the default text editor, if you don’t want to use Vi(m). Run the following command to change to Nano, for instance:

git config --global core.editor nano

Then, after running the “git commit command”, Nano starts instead of Vi(m).


Step 7 – Test Gerrit!

The following commands should run successfully:

./logerrit test
ssh -vvvv logerrit

If they do not run successfully, check out the error messages to see what commands you should run – and also visit the links in the introduction to this guide.


Step 8 – Legal notice

This text should be sent by mail to LibreOffice@lists.freedesktop.org:

All rights reserved for LibreOffice may be licensed under the MPLv2 / LGPLv3 + dual license.

…with the subject line ” license statement”. (More details here.) Note: please only send the statement no earlier than when you post your first submission to Gerrit, and ensure you have permission from your parents!

And now you’re set up to hack on the LibreOffice source code! We’ll follow up this guide with more tutorials soon, so keep an eye on the blog…