Build libreoffice for slackware

Revision as of 12:08, 21 March 2022 by Wikiuser (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Welcome to Simone Giustetti's wiki pages.


Languages: English - Italiano


How-to Build LibreOffice for Slackware Linux

The Slackware Linux distribution does not ship packages for LibreOffice: a suite of office automation programs including a word processor, a spreadsheet software, a presentation program and a database management software. All these tools are indispensable for both home and professional users. The www.slackbuilds.org web site provides some scripts useful to build LibreOffice from source code or to convert the main program, the on-line help packages and localization packages for languages other than English from the official RPMs.

The latter solution is obviously easier and faster as it does not require you to compile everything from scratch, but simply performs a conversion of package format. Unfortunately it supports the most common hardware architectures only: Amd64 and ix86. Anyone using Arm-based machines, such as the Raspberry Pi, on a daily basis has no choice but to compile the entire suite from the source code. Preparing the package is a straightforward and mostly simple task as long as you organize and plan ahead to prepare the necessary resources, dependencies and more. During my first attempt I did not plan and started building as soon as possible, went into trouble and consequently failed. In the following article, I provide some recommendations that could prove useful to avoid mistakes for those who are about to accept the challenge of building LibreOffice.

Development Environment

I used a Raspberry Pi 4 model with 4 Giga Bytes of RAM memory to build LibreOffice. Other models with fewer RAM or the Raspberry Pi 3 can execute the task, but build time will increase proportionally to the gap in resources. My Linux distribution of choice is Slackware Arm 14.2 current. The resulting packages will not be compatible with previous Slackware versions because current, or 15.0 beta, uses hardware support for floating point numbers, while earlier versions of the distribution relied on software emulation. The installed package set was the last available when preparing the Raspberry Pi, but will surely be obsolete when writing this lines as the beta status results in very fast release cycles and update schedule.

The target LibreOffice release is 6.2.8.2. An additional source archive including all of the prerequisite and libraries is available for that one. The additional archive eases the task lifting from your shoulders the burden of installing and maintaining a whole bunch of additional packages. An archive for a newer version of LibreOffice is available: libreoffice-6.4.1.2-srcs.tar.xz, but the hosting site classifies it as insecure and potentially infected by malware. I preferred to ignore it in order not to further complicate the task.

Update: The Python 3 version included in Slackware Arm 14.2 current was recently upgraded from 3.8.1 to 3.8.2. The newer version causes a build failure of LibreOffice 6.2.8.2 while compiling the PyUno library, needed to bind Python to LibreOffice. To solve the issue I was forced to upgrade to release 6.4.1.2 which is not affected by the error.

Lastly I'd like to point out that I preferred to install into directory /opt instead of /usr, set in the SlackBuild script provided by the www.slackbuilds.org web site. I'm sorry, but I have a compulsive need to put things in the right place even when it's not the easier one.

Prerequisites

The main requirement to be able to build LibreOffice consists in a considerable amount of available disk space. With my first attempt I mistakenly thought that 5 Giga Byte could be enough. Compilation failed after the /tmp file system was filled to 100% of its capacity. During the second attempt, I freed up to 20 Giga Bytes of disk space and the resulting amount was enough to finish the job. The files generated during the activity sum up to over 14 Giga Bytes.

The second most important condition to meet is having a lot of time at your disposal. If you don't, you better give up immediately. Producing the package requires many hours of work / compilation with obvious repercussions on the performance of the machine.

The third condition to address is the installation of a lot of libraries required for a full build. A project as complex and big as LibreOffice includes a great number of external libraries to expand its functionality, support as many file formats as possible and to better integrate it with the system. A second archive is distributed alongside the one containing the LibreOffice source code. The second archive includes a version of all the used libraries. It is of course possible to download each and every library and compile it explicitly thus selecting the version and setting the preferred configuration parameters. When a system library is found, the LibreOffice configuration script automatically excludes the corresponding one from the second archive and uses the one installed. The use of system libraries significantly reduces build time, but makes their presence mandatory for every subsequent update of the office suite. During my tests, I used the libraries included in the LibreOffice source code unless:

  • The version in the archive is plagued by known errors or bugs marked as resolved in later releases.
  • The library conflicts with other installed dependencies.
  • The library originates errors while building and the consequent failure of the entire job.

Libraries and prerequisites are listed alphabetically in the following paragraphs.

Apache-ant

It is a build system, another name for a program used to build other ones. It can be considered an alternative to the classic make command. Apache Ant is written in Java and is therefore able to run on any architecture equipped with a Java Virtual Machine or a working JDK. Look below for detailed instructions about installing a JDK on Slackware for the Arm architecture.

There is no Apache-ant package readily available for Slackware, but the www.slackbuilds.org project hosts a build script to produce an updated package.

Apache-ant is not included among the libraries present in the LibreOffice source code and you must always build it separately.

Avahi

Avahi is a free implementation of the networking Zeroconf (zero configuration) service used to assemble a network based on TCP / IP protocols with little or no configuration work, by connecting devices together only. When running, the daemon caches the performed scan results in order to minimize network traffic. It is common technology in the Apple MacOS X area, available for Linux and other operating systems too. LibreOffice has some minor uses for Avahi, for example to check the consistency of links in text documents and to ensure that they point to truly existing resources.

There is no readily available Avahi package for Slackware as the distribution does not include it in its releases. However the www.slackbuilds.org web site distributes a build script which considerably simplifies building a working package.

Avahi is also an optional dependency of other open source projects such as the Trinity Desktop Environement. Assuming you are interested in installing the latter and using it as the default graphical user interface, I recommend compiling Avahi as a standalone package in order not to tie it to LibreOffice.

Avahi requires the Libdaemon library as a dependency, which means you have to install Libdaemon before building Avahi. This same page includes instructions for building Libdaemon, which is not a package included in any Slackware Linux release.

Doxygen

Doxygen is a program used to produce the documentation for a software project directly from the comments included in the source code. The documentation can be saved in various formats including HTML, LaTeX, man pages, PostScript or pdf. While building the LibreOffice tests, doxygen originates a memory error (segmentation fault), failing to produce the document and causing a full build failure. This is a known problem, introduced in recent versions of the program and documented several times in the Slackware Linux changelog, of which I quote some extracts:

  +--------------------------+
  Fri Jan  4 21:44:44 UTC 2019
  a/hwdata-0.319-noarch-1.txz:  Upgraded.
  d/doxygen-1.8.14-x86_64-3.txz:  Upgraded.
     Reverted (for now) to avoid segfault in doxygen-1.8.15.
  
  +--------------------------+
  Sun Jun 30 22:45:12 UTC 2019
  d/Cython-0.29.11-x86_64-1.txz:  Upgraded.
  t/texlive-2019.190626-x86_64-2.txz:  Rebuilt.
     Patched tabu.sty to fix compiling doxygen.
     Thanks to Johannes Schoepfer and nobodino.

When my first tests were conducted SlackwareArm had not yet adopted doxygen version 1.8.16, nor had it regressed to 1.18.4, apparently not affected by the problem, and it was thus necessary to build it in by hand. The software requires some dependencies:

  • fig2dev-3.2.7b-arm-1.txz.
  • qt-4.8.7-arm-10.txz.
  • texlive-2019.190626-arm-4.txz.
  • xfig-3.2.7b-arm-1.txz.

all available among the standard distribution packages. A build script optimized for SlackwareArm can be found on the project website at the following URL: ftp://mirror.slackbuilds.org/pub/slackwarearm/slackwarearm-current/source/d/doxygen/doxygen.SlackBuild. Compilation fails while writing the documentation. The error seems to affect saving the manual in *.pdf format. The production of the manual can be skipped by editing the SlackBuild script and adding this line:

   -Dbuild_doc=no \

along the other configuration options and commenting out line:

   make $NUMJOBS docs || make docs || exit 1

inserting a sharp character ("#") at the beginning of the line:

   # make $NUMJOBS docs || make docs || exit 1

Use the updated script to build a working doxygen package that you can later use to build LibreOffice.

Update: While writing this page SlackwareArm 14.2 current upgraded doxygen to version 1.8.17, which seems unafflicted by the formatting error plaguing the previous ones. You are strongly suggested to upgrade your distribution.

LibDaemon

LibDaemon is needed to build Avahi and as such should be installed before the latter. It is a lightweight library written in the C programming language meant to ease the writing of UNIX daemons.

No readily available LibDaemon package for Slackware which does not include the library among the ones distributed with each release. However the www.slackbuilds.org web site distributes a build script for it. You are encouraged to download the script and the corresponding source code of the library then proceed with a manual build and subsequent installation. The task is easy requiring but a few minutes of work.

LibFreehand

LibFreehand is a library written to add support for files generated by FreeHand: an Adobe / Macromedia program. The second source archive, the one dedicated to prerequisites, includes a recent version of libfreehand, but unfortunately the included version is broken. Building it results in a failure caused by a syntax error. Debugging a small part of a large archive is really difficult especially when you are not allowed to compile the buggy part by itself, thus I choose to install a recent version of the library standalone and debug it.

The full version of the library is afflicted by the same issue. Probably an oversight introduced with a recent commit to the project source code. The script available in the www.slackbuilds.org web page crashes reporting the following error message:

  libfreehand_utils.cpp: In function âvoid libfreehand::_appendUTF16(librevenge::RVNGString&, std::vector<short unsigned int>&)â:
  libfreehand_utils.cpp:166:5: error: expected â;â before âunsignedâ
  166 |     unsigned char outbuf[U8_MAX_LENGTH+1];
        |     ^10:35, 27 April 2020 (UTC)~~
  make[4]: *** [Makefile:567: libfreehand_utils.lo] Error 1

To solve the issue and build a working version of the library I introduced the following patch:

   *** src/lib/libfreehand_utils.cpp       2020-04-12 20:20:37.853604892 +0200
   --- src/lib/libfreehand_utils.cpp       2020-04-12 20:21:51.220597886 +0200
   ***************
   *** 162,168 ****
      while (j < length)
      {
         UChar32 c;
   !     U16_NEXT(s, j, length, c)
         unsigned char outbuf[U8_MAX_LENGTH+1];
         int i = 0;
         U8_APPEND_UNSAFE(&outbuf[0], i, c);
   --- 162,168 ----
      while (j < length)
      {
         UChar32 c;
   !     U16_NEXT(s, j, length, c);
         unsigned char outbuf[U8_MAX_LENGTH+1];
         int i = 0;
         U8_APPEND_UNSAFE(&outbuf[0], i, c);

The above lines of code must be copied in a file called libfreehand_utils.patch to be placed in the same directory containing the libfreehand.SlackBuild script. The script itself requires adding two new lines needed to apply the patch after decompressing the source code archive and correct the syntax error. The lines to add to the script are:

   # Apply patch for libfreehand_utils
   patch -p0 -i ${CWD}"/libfreehand_utils.patch"

A compressed archive including the patch and updated build script is available for download from the following URL.

  • md5: 45cc05f1acb501eabfbad458e2fefe48
  • SHA512: c914b28ba49c6f14d65aa48a99ede120e697305be30969432a286beabfc25577922ac766a13470ce0b85a34b1f5498b703734a60a8b365de66ae6e5301dc3eb8

Update the script and the source code will build smoothly resulting in a package ready for installation.

OpenJDK

It is a Software Development Kit for the Java programming language in other words a set of libraries and tools needed to write programs and applications in Java. In addition to new software, the JDK is used to compile any LibreOffice dependency, extension and component written in Java.

Although a script distributed by the usual www.slackbuilds.org project is available, building a working JDK is a challenging and daunting task. As the script manager points out, the procedure often fails reporting unsystematic errors and repeating the build attempt several times in a row seems to be the only solution to the problem. The same manager reports that only one attempt every 5 concludes successfully. Another argument against compiling your own package is that a working JDK should be used to build another one. The computer version of the chicken and egg paradox. The Sarpi project provides a package for version 8 of OpenJDK. I preferred to install that one, confident that, being a recent release, it would not raise any conflict with LibreOffice. Later tests seem to prove me right so I recommend everyone to install the Sarpi project package.

Perl-Archive-Zip

Perl-Archive-Zip is an extension for the Perl programming language used to write and read compressed archives. The extension is not included in any recent Slackware Linux release and you must build and install your own package. The www.slackbuilds.org project shares a build script to ease the job.

LibreOffice does not include Perl-Archive-Zip among the dependencies source code either, therefore the library must always be built and installed on its own.

Python 3

Python 3 is the latest available major release of the well known programming language. Slackware 14.2 current includes a Python 3 package and no specific action is required to enable it.

Remove Any Installed LibreOffice Release

Installed versions of LibreOffice should always be removed before you start building a new one, otherwise the job will fail while working on the image galleries included in the program suite. The related error messages are somewhat obscure lamenting an error in Makefile ./solenv/gbuild/Gallery.mk, the guilty line being number 55 in my case:

  "/tmp/SBo/libreoffice-6.4.1.2/solenv/gbuild/Gallery.mk:55: recipe for target
     '/tmp/SBo/libreoffice-6.4.1.2/workdir/Gallery/arrows.done' failed
   make[1]: *** [/tmp/SBo/libreoffice-6.4.1.2/workdir/Gallery/arrows.done] Error 1"

but the number can change. Usually the failure is related to the first gallery, but sometimes that one is successfully dealt with while a subsequent one fails. The error arises even when setting a level of parallelism equal to 1. This issue is a well known one resulting in long discussions in forums. The potential cause seems to lie in the build procedure using the installed programs rather than those compiled from scratch. The only solution consists precisely in removing the installed programs then cleaning some environment variables set by the /etc/profile.d/libreoffice.sh script when logging into the PC. If the variables weren't unset with commands

   unset UNO_PATH
   unset URE_BOOTSTRAP

before starting the SlackBuild script, the latter would fail returning an error message like:

  "Bootstrap exception 'component context fails to supply service com.sun.star.ucb.UniversalContentBroker of type
      com.sun.star.ucb.XUniversalContentBroker'"

followed by many gallery related ones similar to the above provided example. Alternatively, you can reboot immediately after uninstalling LibreOffice and compile the new version afterwards.

In short: It is necessary to verify that a version of LibreOffice is not installed on the system before starting a new build:

  ls -la /var/log/packages/*ffice*
  -rw-r--r-- 1 root root 3355381 Jan  1  1970 /var/log/packages/LibreOffice-6.2.8.2-armv7l-1_SBo

Eventually remove the installed version:

  removepkg LibreOffice-6.2.8.2-armv7l-1_SBo

Unset some environment variables

   unset UNO_PATH
   unset URE_BOOTSTRAP

Or reboot.

Run the LibreOffice build script.

  sh ./LibreOffice.SlackBuild

Build Script

As mentioned earlier, I edited the LibreOffice build script to fit my usual file system organization in Linux and some other preferences. In particular:

  • I rearranged the definition of the variables to improve their readability.
  • I added the variable PREFIX to install in a directory other than /usr:
   PREFIX="/opt/${SRCNAM}${SHORT_VERSION}"

LibreOffice 6.4.1.2 programs for example, will be installed in the directory /opt/libreoffice6.4.

  • I updated the lines of code that set the target architecture by explicitly including armv7l and consequently hardware support for floating point numbers:
   # Determine target architecture
   if [ -z "${MARCH}" ]; then
      MARCH=`uname -m`
   fi
   if [ -z "${ARCH}" ]; then
      case "${MARCH}" in
         i?86)
            export ARCH=i486
         ;;
         armv7l)
            export ARCH=${MARCH}
         ;;
         arm*)
            export ARCH=arm
         ;;
         *)
            export ARCH=${MARCH}
         ;;
      esac
   fi
   
   echo -e "\E[0;32m+-----------------------+\E[0;0m"
   echo -e "\E[0;32m|     ARCH=${ARCH}      |\E[0;0m"
   echo -e "\E[0;32m+-----------------------+\E[0;0m"
   
   case "${ARCH}" in
      arm)
         # Use Embedded Application Binary Interface. EABI was created as a common
         # binary interface that should permit code compiled with a specific
         # toolchain/compiler to be linked to projects compiled with another one.
         # arm-slackware-linux-gnueabi and arm-slackware-linux are different
         # targets.
         BUILD_ARCH=${ARCH}"-slackware-linux-gnueabi"
         SLKCFLAGS="-O2"; SLKLDFLAGS=""; LIBDIRSUFFIX=""
      ;;
      armv7l)
         BUILD_ARCH=${ARCH}"-slackware-linux-gnueabihf"
         SLKCFLAGS="-O2"; SLKLDFLAGS=""; LIBDIRSUFFIX=""
      ;;
      i486)
         BUILD_ARCH=${ARCH}"-slackware-linux"
         SLKCFLAGS="-O2 -march=i486 -mtune=i686"; SLKLDFLAGS="-L/usr/lib -ldl"; LIBDIRSUFFIX=""
      ;;
      i686)
         BUILD_ARCH=${ARCH}"-slackware-linux"
         SLKCFLAGS="-O2 -march=i686 -mtune=i686"; SLKLDFLAGS="-L/usr/lib -ldl"; LIBDIRSUFFIX=""
      ;;
      powerpc)
         BUILD_ARCH=${ARCH}"-slackware-linux"
         SLKCFLAGS="-O2"; SLKLDFLAGS=""; LIBDIRSUFFIX=""
      ;;
      s390)
         BUILD_ARCH=${ARCH}"-slackware-linux"
         SLKCFLAGS="-O2"; SLKLDFLAGS=""; LIBDIRSUFFIX=""
      ;;
      x86_64)
         BUILD_ARCH=${ARCH}"-slackware-linux"
         SLKCFLAGS="-O2 -fPIC"; SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64"
      ;;
   esac
  • I updated the line that checks for the installed JDK as follows:
   JAVA=${JAVA:-jdk}

The update was needed to find the Sarpi JDK 8 package. The JDK included configuration script is named /etc/profile.d/jdk.sh instead of /etc/profile.d/openjdk8.sh as wrongly assumed by the build script.

  • I replaced the variable managing KDE 4 with another one meant for KDE 5, which seems to be the graphical environment of choice for recent LibreOffice releases:
   kde5="--enable-kde5" ; [ "${KDE5:-no}" != "yes" ]     && kde5="--disable-kde5"

Options --enable-kde4 and --disable-kde4 seem to be supported no longer and, when set, generate errors with LibreOffice 6.4. I replaced the kde4 variable with kde5 in the configuration part of the script.

  • The configuration lines were updated including the PREFIX variable introduced earlier:
   --prefix=${PREFIX}  \
   --mandir=${PREFIX}/man \
   --docdir=${PREFIX}/doc/$PRGNAM-$VERSION \
   --libdir=${PREFIX}/lib$LIBDIRSUFFIX \
  • The new configuration option --without-export-validation was added to the list. The new option prevents the script from checking the formatting schema for *.odf, *.odt and other files. Schemas can no longer be distributed together with source code for licensing issues and have been removed from the GitHub repository with commit 34dced99c33a97dab86c4538fa267ad4ad4fb41f.
  • The PREFIX variable replaced the /usr built in path in every configuration command, file copy command, and other commands placed in the last part of the script, after the lines invoking make.
  • Lastly, I set the txz package format instead of the classic tgz. Given the package resulting size, I don't mind saving a few megabytes of disk space. Please note: The space savings only concern the package, not the installed files, which are unpacked and decompressed.

In conclusion I include a link to a patch which applies all of the updates described above to the compilation script with a few commands:

  wget http://www.giustetti.net/resource/patch/14.2current/libreoffice/LibreOffice.SlackBuild.patch.gz
  gunzip ./LibreOffice.SlackBuild.patch.gz
  patch -p0 -i ./LibreOffice.SlackBuild.patch

The command sequence must be run in the same directory containing the LibreOffice.SlackBuild script. The consistency of the archive can be checked with commands md5sum and sha512sum using the following comparison values:

  • md5: 0cab4839e5c4eed05eec10e6cc642e2b
  • SHA512: 4ff967fa5dadefdc6cd39b52ea47dd99c103659494618519b272803085088b53f397711b95b88b55339a67b96f29e662c4e37070f173962e5014914dcb47761e

For your convenience I included a link to a version of the modified SlackBuild script: Libreoffice.SlackBuild.gz. In order to use the script you must:

  • download it:
  wget http://www.giustetti.net/resource/slackbuild/libreoffice-6.4.1.2/LibreOffice.SlackBuild.gz
  • Check the integrity of the downloaded archive against checksum values:
  • md5: 60a675277889285137828fd0f20a3a6f
  • SHA512: 60e20e8c79480759bf7182c0d98502233d755c77bdb5ec6b1c9dfd4f9813fa5a93bd93f65ad6ba061823e9323ca28287027ccac3dbcbc5eee6446864d97981cc
  • Unzip it with command:
  gunzip ./LibreOffice.SlackBuild.gz
  • Assign it execution permissions
  chmod u+x ./LibreOffice.SlackBuild
  • Overwrite the original script and start building.

The updated script contains an indication that I modified it. Optimistically, the original author will not be bothered with complaints for errors that I may have inadvertently introduced into the script.

Post Install

Sometimes LibreOffice fails when run immediately after installation. It suddenly shuts down while loading, lamenting that some libraries are unavailable or impossible to find. This usually happens when the configuration script /etc/profile.d/libreoffice.sh is not executed. To solve the problem, run the script by hand using:

  . /etc/profile.d/libreoffice.sh

Or reboot your system. The script will be run automatically after logging successfully in.


CONCLUSIONS

This article is about compiling a recent and working version of LibreOffice on a Raspberry Pi 4. The test environment is equipped with a Slackware Linux operating system for the Arm architecture with packages explicitly customized for the Raspberry Pi, made available by the Sarpi project. All the updates made to solve problems arisen while testing are included, as well as numerous tips for those who are willing to embark on the same task. In conclusion I'd like to thank Christoph Willing for the excellent work done in producing the script for Slackware 14.2, that I used as a starting point for my customization. All changes made to the original SlackBuild script are also included in the form of a patch and a full rewritten script.


For any feedback, questions, errors and such, please e-mail me at studiosg [at] giustetti [dot] net


External links





Languages: English - Italiano