Building LibreOffice on Windows with Cygwin and MSVC: Tips and Tricks

From The Document Foundation Wiki
Jump to: navigation, search

Build dependencies

Before you can start hacking LibreOffice on Windows, you need to follow these instructions to set up a build environment. Do also read our generic building hints.

Install Visual Studio

You need the Microsoft compiler/development suite Visual Studio, which can be obtained from here:

Note there is an edition that is free of charge: Community Edition, that includes everything needed to build all LibreOffice features.

LibreOffice 4.4 requires at least Visual Studio 2012. LibreOffice 5.0 requires at least Visual Studio 2013. LibreOffice 5.4 requires at least Visual Studio 2015. LibreOffice 6.2 requires Visual Studio 2017. Starting with LibreOffice 6.3, building with both VS 2017 and VS 2019 is supported.

Older VisualStudio versions are available at

Visual Studio 2017

Visual Studio 2017 works on current master.

Make sure you install the following components:

  • VC++ 2017 version ... (C++ compiler)
  • Visual Studio C++ core features
  • Windows 10 SDK
  • Windows Universal C Runtime
  • Visual C++ ATL for x86 and x64
  • .NET Framework 4.x.x SDK

You can select these options in the VS 2017 installer.

Visual Studio 2019

Visual Studio 2019 works on current master.

Make sure you install the following components:

  • MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.2x)
  • C++ core features
  • Windows 10 SDK (10.0.xxxxx.x)
  • Windows Universal C Runtime
  • C++ ATL for v142 build tools (x86 & x64)
  • .NET Framework 4.x.x SDK
  • C++ 2019 Redistributable MSMm (only required to build MSI installer)

You can select these options in the VS 2019 installer.


Visual Studio command-line tools use system OEM codepage to output messages to console, when corresponding UI language is installed as part of Visual Studio installation. The OEM codepage on Windows depends on system locale defined using "Language for non-Unicode programs" in intl.cpl applet (description of the setting), and is often incompatible with encoding set in cygwin shell (typically UTF-8). This garbles the output from the tools in the build log.
You might want to make sure that you only install English UI when installing Visual Studio to avoid that problem.

Install Java

No matter what version of Visual Studio you're using, you need a

Install Cygwin and other dependencies


The Easiest way to perform the following is to use LODE , which automates all that is necessary, beyond installing Visual Studio and Java.
If you want to do it the hard way, click the Expand link on the right.

Install Cygwin Requirements

On Windows, you must install Cygwin from Suggested version: 2.11 or later.

The easiest way to do so is to download Cygwin's setup-x86.exe (32-bit) or setup-x86_64.exe (64-bit).

  • It is preferable to use 64-bit Cygwin if possible, because it is less likely to have problems with fork() (see Cygwin FAQ for details).
  • libgpg-error 1.36 does not support gawk 5.0, until an update is released, install gawk 4.2 in Cygwin.

This instruction uses the 64-bit version as an example: Run cmd and navigate to the download dir (if you have trouble navigating, you can also drag setup-x86_64.exe from the file explorer into the cmd window) and copy and paste the command below to run setup-x86_64.exe with the list of required packages preselected.

  setup-x86_64.exe -P autoconf -P automake -P bison -P cabextract -P doxygen -P flex -P gcc-g++ ^
                -P gettext-devel git -P gnupg -P gperf -P make -P mintty ^
                -P nasm -P openssh -P openssl -P patch -P perl -P python -P python3 ^
                -P pkg-config -P rsync -P unzip -P vim -P wget -P zip -P perl-Archive-Zip ^
                -P perl-Font-TTF -P perl-IO-String

This launches the GUI and requires you to manually choose installation paths etc, but the packages passed via command line are pre-selected meaning you just need to accept the selection.

NOTE: installation path of Cygwin mustn't contain non-ASCII letters to avoid problems (if it contains, move folder of the Cygwin installation to a new place and update its Windows shortcuts & Start Menu items).

Alternatively, run the setup-x86.exe or setup-x86_64.exe utility, switch the package view mode to 'Full' by pressing 'View' until 'Full' is displayed beside it, then manually select the packages listed in the above command for installation.

If you upgraded Cygwin, you might have to run the rebaseall command (not needed if you installed Cygwin for the first time):
Close all Cygwin consoles, run c:\cygwin\bin\dash.exe, and in the terminal, launch /bin/rebaseall.

Legacy Cygwin issues

These issues are not present in current Cygwin versions, but the information might be useful for users of older versions.

  • Under Windows 10 x64 version 1511, if you install Cygwin 64-bit, you need Cygwin 2.4.0-0.9 or later (see Cygwin mailing list for details).
  • Cygwin 2.10.0-1 have introduced a breaking change related to treatment of files with FILE_ATTRIBUTE_TEMPORARY attribute set. This interferes with Firebird creating such files in workdir/UnpackedTarball/firebird/gen/Debug/firebird (with names like fb_trace_09y6aq), which results in failing build due to failure to remove a non-empty directory. The problem is fixed in Cygwin 2.11. The error message is like
 rm: cannot remove 'D:/sources/lo-core1/workdir/UnpackedTarball/firebird/gen/Debug/firebird': Directory not empty
If updating Cygwin is not an option, a workaround is to open the directory using a file manager (like Windows File Explorer) and remove the file(s) left there manually.

Other dependencies

After having installed Cygwin, open Cygwin command line, and perform next steps:

Install GNU make

A Win32 build of GNU make 4.0+ is made available (and required) for building LibreOffice.

It's easiest to put it in /opt/lo/bin, where configure will automatically find it; you can also use another location and set the MAKE variable. Either prepend /opt/lo/bin to PATH, or alternatively, when you build LibreOffice, always call "make" with the absolute path /opt/lo/bin/make (or wherever you put it). LibreOffice cannot and should not use Cygwin's /usr/bin/make.

  mkdir -p /opt/lo/bin
  cd /opt/lo/bin
  mv make-4.2.1-msvc.exe make
  chmod a+x make
Install 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 command later.

  mkdir -p /cygdrive/c/sources
  cd /cygdrive/c/sources
  tar -xjvf apache-ant-1.9.5-bin.tar.bz2
Clone the LibreOffice source code repositories

NOTE: sources should be in a relatively short path to avoid exceeding the file/pathname limit and the destination path cannot have any space in it.

  cd /cygdrive/c/sources
  git clone git:// libo-core
Optionally create build directory

You can build LibreOffice into another directory than your checkout. This helps keeping the source code tree clean and eases building multiple versions, however it does stop the Visual Studio IDE Integration from working.

If you want to build into a separate directory, say /cygdrive/c/build, enter these commands:

  mkdir /cygdrive/c/build
  cd /cygdrive/c/build

Otherwise change directory to the /cygdrive/c/sources/libo-core folder:

  cd /cygdrive/c/sources/libo-core
Configure and build the code

Now run to configure the build:

  /cygdrive/c/sources/libo-core/ \
               --with-external-tar=/cygdrive/c/sources/lo-externalsrc \
               --with-junit=/cygdrive/c/sources/junit-4.10.jar \
               --with-ant-home=/cygdrive/c/sources/apache-ant-1.9.5 \
               --enable-pch --disable-ccache \
               [additional switches, if you know what you are doing :-) ...]

Note that it's not recommended to use ccache on Windows. If you have it installed in your Cygwin environment, be safe and disable it with --disable-ccache (as in the command above).

If the script complains that it cannot find some header files, it is possible that it cannot locate the your Windows SDK or that it finds a corrupted one. This may happen if you installed multiple version of Visual Studio on your computer, especially if you installed a Beta version, and even if you uninstalled those. In this case, you may use the --with-windows-sdk=7.1A, possibly replacing 7.1A with another version of the SDK to select a specific uncorrupted version. For Visual Studio 2015 use --with-visual-studio=2015.

Save a copy of the last used parameters in the file autogen.input. It will not be overridden by when using other parameters. If is called again without parameters, it will fetch its input from autogen.input if it is present.

Don't forget to specify --with-jdk-home when you use AdoptOpenJDK in zip format, because detects JDK's paths from registry JDK's installer downloadable from Oracle sets. Other JDKs may need this option too(not tested).

Read the summary output from the command. If it did not report any errors or relevant warnings, then all that is left to do is to run the right version of make to build LibreOffice:

   /opt/lo/bin/make gb_COLOR=1  # gb_COLOR=1 enables colored output

If the build process fails at this point with the error error C3861: 'InetPtonW': identifier not found, this is because of a bug in the build process for Windows SDK 8. You may work around this by using the --with-windows-sdk=7.1A option.

Run LibreOffice

When the build has finished without errors, you can run your fresh build of LibreOffice using


Microsoft Visual Studio Project Integration

The LibreOffice build system can generate project file for some IDEs including -- thanks to Honza Havlíček's excellent work -- Microsoft Visual Studio: (note that this does not allow a full build so you still need to use Cygwin to do full builds)

Build a project file for Visual Studio

The IDE integration script is written in python3, which is not installed by default (using the lode method), please install it in cygwin before running the make command. After a complete build of LibreOffice was successful, execute the following command to generate a Visual Studio project for Visual Studio 2017:

  $ /opt/lo/bin/make vs2017-ide-integration

If the generation is successful, the resulting solution file LibreOffice.sln will be placed in the root directory of the build and can be opened with Microsoft Visual Studio.

On older branches, projects for older versions of Visual Studio may be available/required:

  $ /opt/lo/bin/make vs2015-ide-integration


  $ /opt/lo/bin/make vs2013-ide-integration

In order for the solution file to open correctly in Visual Studio, the LibreOffice build must be done to the same directory as the source code; separating the source and build directories stops the IDE integration from working.


It is a frequently asked question, usually coming from free software purists, why we use proprietary compiler instead of a free one (i.e. gcc).

  • ABI backwards-compatibility for compiled extensions. There is some resistance to breaking that.
  • So far MSVC produces faster, smaller binaries.
  • There are some features in the code that don't compile with MinGW. They use API that MinGW does not provide headers for etc.
  • There are open questions around how we would run unit tests in a MinGW cross-compilation environment.
  • There are open questions around how well gdb works on Windows; the MSVC C++ debugger is really quite good.

Autogen options

Something like the following in the autogen.input file is known to produce a working build:


Of course, change the information behind ='s to fit your needs; set the paths to what you have used when installing various prerequisites.

You also need to specify the path for ant with --with-ant-home=<cygwin path of ant>.

64-bit Visual Studio build

A port for 64-bit Windows is working on master with all supported compilers. To build it, use the --enable-64-bit flag to configure.

Visual Studio 2019 compiler

Visual Studio 2019 is another supported version on current master.

Visual Studio 2017 compiler

Visual Studio 2017 is a supported version on current master.

Visual Studio 2015 compiler

Visual Studio 2015 is known to work on libreoffice-6-1, libreoffice-6-0 and some older branches.


You need to install Update 3 for Visual Studio 2015, or newer, or the build will fail.

   checking whether MSVC 2015 compiler C:/PROGRA~2/MICROS~3.0/VC/bin/cl.exe -arch:SSE is at least SP3... no
   configure: error: When using MSVC 2015, at least SP3 must be installed

Also please make sure you've explicitely enabled "Programming language Visual C++" during installation, otherwise the default install miss certain required features.

Visual Studio 2013 compiler

Visual Studio 2013 was used to build libreoffice-4-5, libreoffice-5-2 and libreoffice-5-3 releases.

Switching to non default compiler

Specify which Visual Studio version to use in case several are installed.

If not specified, the order of preference is 2015, 2017 for libreoffice-6-1 (and older branches), 2017 is used for master.


Running Glade on Windows

To edit dialogs (.ui files), you need Glade. There is an old version for Windows but it doesn't support all properties that are needed for LibreOffice dialogs.

So you need to install Glade in Cygwin:

  • Install Glade in Cygwin by running the Cygwin Setup, then install the following packages:
X11, X11 fonts, Gtk3, Glade, OpenGL
  • Add this to your .bashrc:
export GLADE_CATALOG_SEARCH_PATH=<path_to_core>/instdir/share/glade
  • Open one Cygwin console and run:
X -multiwindow
  • Open another Cygwin console and run:
DISPLAY=:0.0 glade.exe

That's it, you should now run Glade ≥ 3.18

Known Problems

Cygwin Shell

You will use Cygwin Bash Shell for the whole build process. You must install all the build dependencies above before starting the shell to run autogen because autogen needs some environment variables to find the tools.

If you see an error similar to the following when running

   $'\r': command not found

This means that that windows style newline characters are creating issues with the Cygwin Shell. The good way to solve this is to configure git to clone with UNIX line ending. To do so, in git bash:

   git config --global core.autocrlf input

Big List Of Dodgy Apps

If you get mysterious build breaks, building is very slow or your systems hangs totally, check if you are running an application which interferes with Cygwin. For a list of known offenders, see this point in the Cygwin FAQ.

Buildability of 'master'

If you are building the Windows build for the first time, it is recommended that you check the current state of . If you see recent "green" builds, it is a good time to try - otherwise it might happen to you that you'll have to fix the build yourself. The buildability on Windows has improved recently with the introduction of the MinGW and more stable native Windows tinderboxes, but still there might be a day or two when 'master' is not buildable on Windows.

The usual recommendation is to just pull and try again, and once you have a build, don't pull in the tree any more, but do your hacking in it. Clone a different tree and iterate pulling and building in that until it again works, then switch. Repeat.

Alternatively, if you find a known good state (a green box) for Windows on the Tinderbox side back in history, you can do:

git checkout -b my_workbranchname ${last_good_commit}

to start working on a branch starting at the last good state.

BitDefender / other Anti-Virus / security tools breaking the build

If your build fails with a FileNotFoundError: such as The system cannot find the file specified: '../../../dist/out/bin\\example.exe', there's a good chance your Anti-Virus is quarantining or deleting important files.

Another potential source of problems are the sample documents (those labeled CVE) that check for known vulnerabilities to ensure they don't reappear again. In the source they are stored encrypted to avoid triggering the warnings, but when the corresponding test is run, the original is created in the temp directory and tools such as BitDefender can flag it.

If you want to run these tests, disable monitoring of the temporary build-directories <root of repo>\*\pass and C:\cygwin\tmp in your Anti-Virus tool. For Windows 8 and 10 you will need to disable Windows Defender launch - search for and launch 'defender' from the shell.

You can also use the --disable-cve-tests autogen flag to skip the tests that are known to cause trouble.

Also note that Anti-Virus tools can slow down your build quite a bit, if you want to build fast you should disable real time monitoring of the source tree and the temporary files directory C:\cygwin\tmp.

Norton Antivirus breaking the build

Norton Antivirus and Symantec Endpoint Protection complain about certain files that the build produces. It finds the following files (in a build without "--enable-dbgutil" )

Malware: Suspicious.Cloud
Malware: Suspicious.Cloud.5

Files with * are needed for the build - exclude them from the virus scan!

The following files appear with varying names (????) in a release build, so you cannot exclude them from the scan.


Current workaround: Don't do release builds (unless you are allowed/willing to switch off the virus scanner).

System PATH causing weird build breakage

If you experience weird build breakage that no one else seems to experience, check your PATH value and try cleaning it. Note that you need to open a new shell and re-run in order for the new system PATH value to take effect in your build. Some people have experienced a build failure in the shell module due to their system PATH including a path to an older OOo installation which had a DLL of the same name as the one that the build uses.

Windows Update automatically reboot during compilation

Sometimes Microsoft Windows reboot during compilation. It happen because Windows Update updates operating system and reboot. To stop windows update from command line, you can enter following command in command box;

C:> net stop wuauserv

It stops a Windows Update service process.

Failing PDF signing tests

On Windows, it can happen, that PDF signing tests are failing:

  [build CUT] xmlsecurity_pdfsigning
  warn:sfx.appl:2956:6324:sfx2/source/appl/app.cxx:193: No DDE-Service possible. Error: 16399
  warn:svl.crypto:2956:6324:svl/source/crypto/cryptosign.cxx:1415: CryptAcquireCertificatePrivateKey failed: Das Zertifikat und der private Schlüssel für die Entschlüsselung wurden nicht gefunden.
  warn:vcl.filter:2956:6324:vcl/source/filter/ipdf/pdfdocument.cxx:846: PDFDocument::Sign: PDFWriter::Sign() failed
  C:/Users/davido/projects/libo/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx:174:PDFSigningTest::testPDFAdd assertion failed
  - Expression: aDocument.Sign(aCertificates[0], "test", true)

Solution: Remove expired Own Certificate:

  1. Start certmgr
  2. proceed to Own Certificates
  3. Remove expired certificate
  4. Repeat the tests
  5. Done

Short filenames (8.3 filenames)

If you get an error like the following one:

  configure: error: converted path "C:/PROG~1/Microsoft SDKs/Windows/v8.1A/bin/NETFX4~1.1TO/" still contains spaces. Short filenames (8.3 filenames) support was disabled on this system?
  Error running configure at ./ line 300.

Then ensure 8.3 name creation is enabled. Open the Command Prompt as administrator and run:

  fsutil 8dot3name query c:

Also, check that the conflicting folder (in this case, "Microsoft SDKs") has a corresponding 8.3 filename. For example:

  cd C:\Program Files (x86)\
  dir /x M*

This will print a list of folders beginning with "M" and their associated 8.3 filenames. If "Microsoft SDKs" does not have a short filename, you can rename it to "tmp", then create a new folder "Microsoft SDKs", check that it has a short filename and move the contents of "tmp" to "Microsoft SDKs".

Cygwin and git

The main problem is the cygwin-git is very slow, but the git for windows is okay.

The alternative is:

Here the times, it is the same computer and repo and was not the first call of:

git status

git Version Time [sec]
cygwin 2.21.0 20
win 2.22.0 1

After that I'm using the win-git in git-bash

BUT a mix between cygwin-git and win-git is not always compatible, when you change you should be renew (clone) the git repositories with win-git

Other known problems

  • Paths that include /opt cause problems with some external modules; it is best to avoid having your source tree in /opt; or use --disable-orcus to overcome this.
  • Asian locale builds sometimes fail due to encoding issues in the source code; in these cases, patches to fix those problems are appreciated. Alternatively, configure Windows for a US locale.

Using a Windows program as your git editor

Paths under Cygwin are an endless source of nightmares. This section documents using Notepad++ as your git editor under Cygwin. It assumes you are using the 64-bit version of Notepad++ (adjust the path, if using the 32-bit version).

Below you will find a wrapper script written by Gene Pavlovsky (original gist in GitHub).

  1. Save the script as into the bin directory in Cygwin's root (so it is in the PATH). When saving the using Notepad++, do this first to make sure it has Unix line endings: from the "Edit" menu, select "EOL Conversion" -> "UNIX (LF)".
  2. In a Cygwin shell inside the bin directory, give this command to create a symbolic link:
    ln -s cygrun
  3. Give this command in your home directory:
    git config --global core.editor "cygrun -w 'C:/Program Files/Notepad++/notepad++.exe' --wait"
    or alternatively edit your .gitconfig to contain this editor block:
    editor = cygrun -w 'C:/Program Files/Notepad++/notepad++.exe' --wait
    The --wait is important, as it forces git to wait until you close the file.

Bonus: if you want to define Notepad++ as the default editor of your shell and also access it through a handy "np" alias, add these to the .bashrc file in your home directory:

export EDITOR="'/cygdrive/c/Program Files/Notepad++/notepad++.exe'"
alias np="'/cygdrive/c/Program Files/Notepad++/notepad++.exe'"

Remember to be very careful with the line endings, when creating new files and use the Edit -> EOL Conversion.

The cygrun script:

# Run a program, converting UNIX and Windows format path arguments.
# Install in Cygwin's `bin` dir or elsewhere in your path. 
# Create a symlink for convenience: `ln -s cygrun`.
# Use `cygrun -w windows-program unix-path ...` to run Windows programs (e.g. from UNIX software).
# E.g., in my .gitconfig core.editor is set to `cygrun -w 'C:/Program Files/Notepad2/Notepad2.exe'`.
# Use `cygrun [-u] unix-program windows-path ...` to run Cygwin programs (e.g. from Windows software).
# Usually not needed since Cygwin translates Windows paths automatically (e.g. `ls 'C:\Windows'` works).
# Still it can be useful in case a Windows program might produce paths that mix backslashes and forward slashes,
# e.g. in Apache Ant `${dist.dir}/file` evaluates to `C:\path\to\project\dist/file`, which Cygwin won't
# translate automatically. So, to deploy the file, I use `cygrun -u scp ${dist.dir}/file ${deploy.url}`.
# Use the `-b` option to detach from tty, run the process in background, and return immediately.
# There is currently a limitation on passing non-path arguments to a program. Since there is no way
# to automatically distinguish path arguments from non-path arguments, all of the arguments are passed
# to `cygpath`. As long as non-path arguments don't contain `/` or `\` characters, and `-a` or `-C`
# options are not used, `cygpath` will return the arguments unmodified - no problem.
# Due to this, the `-a` and `-C` options are disabled at the moment.
# TODO: Add an option allowing to specify index positions of path arguments (comma-separated, support ranges).
# Most of the options are passed as is to `cygpath`, which is used for path conversion.

set -e -o pipefail

usage() {
  local code=${1:-2}
  test $code -ne 0 && exec >&2
  echo "Usage: $(basename "$0" .sh) [options] program [argument]..."
  echo 'Run a program, converting UNIX and Windows format path arguments.'
  echo 'Output type options:'
  echo '  -d, --dos             print DOS (short) form of NAMEs (C:\PROGRA~1\)'
  echo '  -m, --mixed           like --windows, but with regular slashes (C:/WINNT)'
  echo '  -u, --unix            (default) print Unix form of NAMEs (/cygdrive/c/winnt)'
  echo '  -w, --windows         print Windows form of NAMEs (C:\WINNT)'
  echo 'Path conversion options:' 
  echo '  -U, --proc-cygdrive   Emit /proc/cygdrive path instead of cygdrive prefix'
  echo '                        when converting Windows path to UNIX path.'
  echo '  -c, --codepage CP     print DOS, Windows, or mixed pathname in Windows'
  echo '                        codepage CP.  CP can be a numeric codepage identifier,'
  echo '                        or one of the reserved words ANSI, OEM, or UTF8.'
  echo '                        If this option is missing, cygrun defaults to the'
  echo '                        character set defined by the current locale.'
  echo "Other 'cygpath' options:"
  echo '  -f, --file FILE       read FILE for input; use - to read from STDIN'
  echo "  -o, --option          read 'cygpath' options from FILE as well (for use with --file)"
  echo '  -h, --help            output usage information and exit'
  echo 'Run options:'
  echo '  -b, --background      run in a new session'
  echo '  -n, --dry-run         print the command that would be executed, and exit'
  exit $code

run() {
  local -n _run_args=$2
  if test "$dry_run"; then
    test "$chdir" && printf 'cd %s\n' "$chdir"
    printf '%s\n' "$1 ${_run_args[*]}"
    test "$chdir" && cd -- "$chdir"
    if test "$background"; then
      setsid "$1" "${_run_args[@]}" </dev/null &>/dev/null &
      exec "$1" "${_run_args[@]}"

declare opts fileopts chdir background dry_run
while test $# -gt 0; do
  case $1 in
      opts="${opts} $1"
      opts="${opts} $1 $2"
      opts="${opts} -i $1 $2"
      usage 0
      script="$(basename "$0" .sh)"
      echo "$script: Unknown option: $1" >&2
      echo "Try '$script --help' for more information." >&2
      exit 2
test "$chdir" && opts="$opts -a"

test "$program" || usage

declare -a args
test $# -gt 0 -o "$fileopts" && mapfile -t args < <(cygpath $opts -- "$@" || exit 1)
run "$program" args

See also