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.
These instructions assume you have not installed any WSL container. The automated steps install an Ubuntu WSL container and the required packages only, if existing containers are not found.
Windows Subsystem for Linux Documentation
Dev Drive
Windows 11 offers the possibility to create storage volumes called Dev Drives, which improve performance when doing development. Using a Dev Drive has the additional benefit of avoiding errors caused by anti-virus tools. If you don't use a Dev Drive, make sure your anti-virus software will not cause any problems. The instructions below assume LibreOffice source code goes into your user directory, so if you decide to use a Dev Drive, adapt accordingly.
Cloning the source code and installing build dependencies
Launch Windows Command Prompt as a normal user and run the following:
Command to install Git (run as normal user in Command Prompt) |
---|
|
Start Git Bash and run the following:
Command clone LibreOffice source code (run in Git Bash) |
---|
|
The cloning options use a more efficient protocol and prevent messing up line endings in files. If you want to set these options globally as the default, give the command git config --global protocol.version 2 ; git config --global core.autocrlf false
Launch another Command Prompt window as administrator (right-click, Run as administrator). Run the following:
Winget commands to install Visual Studio and other dependencies (run as administrator in Command Prompt) |
---|
|
Switch back to the Command Prompt window of your normal user and run the following:
Winget command to install more needed dependencies and a WSL Ubuntu distribution (run as normal user in Command Prompt) |
---|
|
This step also creates an autogen.input file in the LibreOffice source code directory with build options. Open the file in a code editor and uncomment the line that says #--enable-dbgutil
, if you want to do LibreOffice development with debugging capabilities.
Building LibreOffice
Switch to Git Bash and run the following:
Commands for installing commit hooks, doing configuration and building of LibreOffice (run inside Git Bash) |
---|
|
To also run the tests:
Command to start the build and tests (run inside Git Bash) |
---|
|
If you hit issues, first consult the known problems section of the main Windows build article.
Running your build
When the build is finished, you can start LibreOffice with:
instdir/program/soffice
If you want to run specific applications like Writer or Calc, you can invoke:
instdir/program/soffice --writer
instdir/program/soffice --calc
Troubleshooting/Special Scenarios
winget command fails in fresh windows installation |
---|
windows does some async initializing when logging in the first time/winget might not be fully available from the start. Wait a few minutes or try again.To force it: "If you have recently logged in as a user for the first time and find that WinGet is not yet available, you can open PowerShell and enter the following command to request this WinGet registration:
."
might also work to force that, but will likely require you to reboot
|
enabling nested virtualization in hyper-v |
---|
while the wsl-as-helper method also works with wsl1, the setup assumes wsl2 is available/can be used by default. There is no UI option in hyper-v manager to enable nested virtualization, you have to do it via a powershell command (assuming your BIOS settings/hardware allows for this in the first place):
(don't forget to replace the placeholder with the actual name of the VM, VM needs to be powered off for the command to succeed)
|
using wsl1 |
---|
In case you cannot (or don't want to) use wsl2, it is also possible to use wsl1 instead, to do so install the windows compontent for wsl1, set the default distribution version to 1, then install the distribution. As Administrator:
As regular user:
|
disable Defender on a Dev Drive |
---|
You can disable the virus-scanning on Dev Drives completely (by default it would use an async-mode). For this the Dev Drive needs to be trusted (automatically trusted when you created it int he running system, but not when mounting a disk with a Dev Drive created elsewhere). Query the state with
You can explicitly trust it with
To disable the filesystem filter for the BitDefender/disable the antivirus scanning use:
Note that this then applies to all Dev Drives, you cannot selectively disable it for a single one, so use responsibly.
|