Development/BuildingOnWSLWindows
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Introduction
Windows Subsystem for Linux (WSL) is a mechanism to run Linux applications unchanged in Windows. You can use WSL to build LibreOffice for Linux and run it on Windows, or you may use WSL as a helper to configure LibreOffice build, and then use GNU make to build it for Windows using Visual Studio. Here we discuss building for Windows. To build for Linux, please refer to Development/BuildingOnWSL.
The first step to build LibreOffice using WSL is to install WSL itself. You can follow instructions on Microsoft Website to install WSL, preferably WSL 2.
Windows Subsystem for Linux Documentation
There are multiple Linux distributions available in Microsoft store, and you can choose your desired distribution. The following instructions use Ubuntu, but the build is very similar across different distributions.
Build dependencies
Ubuntu dependencies
You need a few packages from WSL for the configuration. On Ubuntu, you can invoke:
Commands to install dependencies (run inside WSL shell) |
---|
|
Windows build dependencies
You have to install the dependencies for Windows build, and specifically Visual Studio compiler. For more information, please refer to the Windows build instructions. Additionally, select "Git for Windows" from the components.
Other dependencies like Cygwin are not needed, as WSL provides an alternative to them.
Notes about Git
The build instructions should be invoked from the git bash shell.
You have to make sure that line endings are set correctly, otherwise you may get various errors. You can use this command to set them correctly.
Configure git (run inside git bash) |
---|
|
Setting this option is also possible during the installation of git for Windows.
Also, make sure that you don't have the wslsys
program in your path.
GNU Make for Windows
You have to download GNU Make for Windows, and copy it to somewhere in the path.
Commands to install make (run inside git bash)
|
---|
|
You should be able to see the version of the GNU Make with make --version
.
Be careful to use this Windows Make - the build will fail, if you use Make from Linux!
Ant and JUnit
You can extract them anywhere, they don't have to be installed. If you don't want to use Junit, it can be disabled with --without-junit in the autogen.sh command later.
Commands to install ant and junit (run inside git bash)
|
---|
|
Also works with the combination of junit 4.13, hamcrest 2.2 and Apache Ant 1.10.12
Strawberry Perl
You can download and install Strawberry Perl from strawberryperl website.
Cloning and building
Start git bash, and try the next steps inside it. You can clone the LibreOffice core repository with:
Clone LibreOffice code (run inside git bash) |
---|
|
You need a suitable configuration for the build that you can put inside autogen.input
file. This is a suggested configuration, which assumes JDK is in c:/jdk
, Strawberry Perl is in c:/strawberry
and JUnit and ant are in c:/sources
.
sample autogen.input
|
---|
|
It is recommended to add the source and build folder to the antivirus exclusions folders to speed up the build, and make sure your anti-virus software will not cause any problems.
After that, you should configure the build with:
Command to configure build (run inside git bash) |
---|
|
You may see a warning like this, even after a successful configuration:
* WARNING : To speed up builds and avoid failures in unit tests, it is highly recommended that you exclude the build and source directories associated with LibreOffice in the following Antivirus software: *Windows Defender
The next step is to invoke the make
command. You can simply invoke:
Command to start the build (run inside git bash) |
---|
|
And to also run the tests:
Command to start the build and tests (run inside git bash) |
---|
|
Running your build
When build is finished, you can start LibreOffice with:
$ instdir/program/soffice
If you want to run specific application like Writer or Calc, you can invoke:
$ instdir/program/soffice --writer
$ instdir/program/soffice --calc
Tips
Error During the Build
First, you have to make sure that the configuration phase completes correctly. Sometimes when some libraries or other requirements are missing, this phase does not complete correctly. Then, you have to fix the issue, and try again with ./autogen.sh
. After the configuration phase completes correctly, you can run make
and if everything is set correctly, you should see it finishing without error.
If you face errors like this:
src\lxml\etree.c(105): fatal error C1083: Cannot open include file: 'Python.h': No such file or directory C:\Users\user\LIBREO~2\tmp\xmlXPathInit09l2r90w.c(1): fatal error C1083: Cannot open include file: 'libxml/xpath.h': No such file or directory
then, please add --without-lxml
to autogen.input
, as it does not work at the moment, due to incompatibility.