Difference between revisions of "Compiling Inkscape on Windows with MSYS2"

From Inkscape Wiki
Jump to navigation Jump to search
(→‎Packaging: dist-win-*-fast not available anymore (except for 7z, but let's keep it simple))
m (remove "work-in-progress" marker)
 
(9 intermediate revisions by 3 users not shown)
Line 3: Line 3:
MSYS2 does not only offer a convenient build environment for compiling Inkscape but also provides all necessary build tools and dependencies making it extremely simple to get started with Inkscape development.
MSYS2 does not only offer a convenient build environment for compiling Inkscape but also provides all necessary build tools and dependencies making it extremely simple to get started with Inkscape development.


== Installing MSYS2 ==
== Installing Build Dependencies Easily ==


[[File:MSYS2 shells.png|600px|thumb|
In the basic case, you can install all the needed tools with a one-click script. This is supported for Inkscape 1.5 or newer, running on standard 64bit Windows (not ARM). In other cases, please see below "Installing Build Dependencies Manually".
<div>Always use the proper shell
<ul>
<li>"MinGW 32-bit" for compiling 32-bit Inkscape</li>
<li>"MinGW 64-bit" for compiling 64-bit Inkscape</li>
<li>'''Never''' use the "MSYS" shell for compiling Inkscape, only use it for updating MSYS2 itself.</li>
</ul>
<br/>
You can identify the different shells according to the the purple text string in the console window (<tt>MINGW32</tt>, <tt>MINGW64</tt> or <tt>MSYS</tt> respectively).
</div>]]


To set-up MSYS2 and download the necessary dependencies only two steps are required:
# Get the buildtools folder from the Inkscape git repository. One way to do this is the following:
* '''Step 1''' &mdash; Install MSYS2
#* Download the following ZIP https://gitlab.com/inkscape/inkscape/-/archive/master/inkscape-master.zip?path=buildtools
** Download the installer from the [http://www.msys2.org/ MSYS2 homepage] (a 64-bit version of Windows 7 or later is required to run MSYS2 and build Inkscape).<br/>Start the installation and follow the instructions on screen. Wait until it finishes.
#* Unpack it
** Start an MSYS2 '''MSYS''' shell (you can work with the one launched by the installer, use the "MSYS2 MSYS" shortcut in the start menu or launch "msys2.exe" in the installation directory). <br/> Execute the command <code>pacman -Syuu</code>. This will start a full system upgrade and ensures that you have the latest versions of all core libraries.
# Double-click on <code>windows-deps-clickHere.bat</code>
** Repeat the previous step until no new updates are found.
#* If you get a warning "Windows protected your PC. Microsoft Defender prevented an unrecognized app from starting.", click on "More information" and "Run anyway".
* '''Step 2''' &mdash; Download dependencies
#* Follow the instructions in the Terminal window. (Press Enter to confirm.)
** Start an MSYS2 '''MinGW''' shell (use the "MSYS2 MinGW 32/64-bit" shortcut in the start menu or launch "mingw32/64.exe" in the installation directory).<br/>Choose the shell in this step (32-bit or 64-bit) according to whether you want to build a 32-bit or 64-bit version of Inkscape later. 64-bit is recommended.
#* Confirm Administrator rights if Windows asks you to
** Execute the command <code>curl https://gitlab.com/inkscape/inkscape/-/raw/master/buildtools/msys2installdeps.sh | bash</code><br/>(The command downloads and runs the script [https://gitlab.com/inkscape/inkscape/blob/master/buildtools/msys2installdeps.sh msys2installdeps.sh]. Alternatively, you can copy-paste the script into the console or download it, change to the folder containing the file and type <code>./msys2installdeps.sh</code>. If you already have a copy of the Inkscape source it should also be included in the "buildtools" folder.)
# Wait a few hours until the script says Done. Then you can compile Inkscape as described later.
** Relax and take a break, as this may take some time (a few minutes at best, but it can take significantly longer if you have a slow internet connection or the server load is high).  


⚠️ ''Warning: Always make sure to use the proper MSYS2 shell (see screenshot to the right). Dependencies are separate for 32-bit and 64-bit Inkscape.''
== Obtaining Inkscape Source ==


<br clear=all>
''Note: For general instructions on how to use Git see [[Working with Git]].''


== Obtaining Inkscape Source ==
As MSYS2 provides the revision control software Git you do not need to download it separately.


''Note: For general instructions on how to use Git see [[Working with Git]].''
Open the MSYS2 '''UCRT64''' (!!!) shell from the start menu.


As MSYS2 provides the revision control software Git you do not need to download it separately. Simply open the MSYS2 MinGW shell and run the command
Run the command
<pre>git clone --recurse-submodules https://gitlab.com/inkscape/inkscape.git master</pre>
<pre>git clone --recurse-submodules https://gitlab.com/inkscape/inkscape.git master</pre>
This creates a folder called "master" in the current working directory (usually the home folder located at "C:\msys64\home\Your_Username" or similar) in which the clone of the source repository is created.
This creates a folder called "master" in the current working directory (usually the home folder located at "C:\msys64\home\Your_Username" or similar) in which the clone of the source repository is created.
Line 45: Line 35:
== Building Inkscape with MSYS2 ==
== Building Inkscape with MSYS2 ==


To compile Inkscape open the MSYS2 MinGW shell (remember to use the correct shell, i.e. 32-bit or 64-bit, matching the dependencies you downloaded above and the version of Inkscape you want to build).
*'''Read carefully:'''  To compile Inkscape open the MSYS2 '''UCRT64''' (!!!) shell from the start menu (or launch C:\msys64\ucrt64.exe)
*⚠️ ''Warning:'' Using the right shell type is important so that the right type of Inkscape is built and the right dependencies are installed:
** UCRT64 is the standard for compiling 64-bit Inkscape
** (MinGW 64bit / 32bit was used until mid 2023 to build 64/32bit versions. ARM may be used in the future to build for ARM processors.)
** '''Never''' use the "MSYS2 MSYS" shell for compiling Inkscape, only use it for updating MSYS2 itself.
 
'''Double-check:''' The shell window must show "'''UCRT64'''" in purple text. If it shows "MSYS" then you have the wrong shell.


Then execute the following commands:
Then execute the following commands:
Line 77: Line 73:
'''''That's it!'''''<br/>
'''''That's it!'''''<br/>
Afterwards you should have a complete binary distribution of Inkscape in the folder "build/inkscape/" that can be run on any machine running Windows 7 or later.
Afterwards you should have a complete binary distribution of Inkscape in the folder "build/inkscape/" that can be run on any machine running Windows 7 or later.
== Running Inkscape ==
Simply execute <code>inkscape.exe</code> from the "build/'''inkscape'''/bin" directory (not "build/bin") created in the previous step. (The <code>ninja install</code> command takes care of copying all required files into this directory.)


== Packaging ==
== Packaging ==


If you only want to run Inkscape you do ''not'' need to follow these instructions. Simply execute <code>inkscape.exe</code> from the "build/inkscape/bin" directory created in the previous step, the <code>ninja install</code> command takes care of copying all required files into this directory.
If you only want to run Inkscape you do ''not'' need to follow these instructions. See "Running Inkscape" above.


To package those files for distribution (this should only concern package maintainers or people who want to improve the installer code) we offer a set of CMake convenience targets that can be executed as follows:
To package those files for distribution (to give it to other people, or make a setup file for other computers), you can use the following commands:
* <code>ninja dist-win-7z</code> &ndash; generate binary 7z archive. You'll need to install [http://www.7-zip.org/ 7-Zip].
* <code>ninja dist-win-7z</code> &ndash; generate binary 7z archive.  
* <code>ninja dist-win-exe</code> &ndash; generate .exe installer. You'll need to install [http://nsis.sourceforge.net/ Nullsoft Scriptable Install System (NSIS)] version 3 or later.
* <code>ninja dist-win-exe</code> &ndash; generate .exe installer.
* <code>ninja dist-win-msi</code> &ndash; generate .msi installer. You'll need to install [http://wixtoolset.org/ Windows Installer XML (WiX Toolset)].
* <code>ninja dist-win-msi</code> &ndash; generate .msi installer.
* Additionally there's a <code>dist-win-all</code> target (executes all of the above in parallel).
* Additionally there's a <code>dist-win-all</code> target (executes all of the above in parallel).


Line 92: Line 91:
== Troubleshooting ==  
== Troubleshooting ==  


If the MSYS shell does not open, try rebooting.
=== Issues with MSYS2 ===
 
; The MSYS2 shell does not open.
: Try rebooting.
'''I have trouble updating an existing, older MSYS2 installation'''
 
* Check <nowiki>https://www.msys2.org/news/</nowiki> for any recent news that may describe your issue and explain how to solve it.
* The most straightforward solution is often to re-install MSYS2:
** Uninstall the old MSYS2. Make sure to completely remove the C:\msys64 directory if the uninstaller does not do the job but remember to back up any personal data such as your home folder C:\msys64\home\)
** Download a fresh installer from <nowiki>https://www.msys2.org/</nowiki> and start over as described above.
 
=== Issues with building Inkscape ===
; The command `ninja` errors out after an MSYS2 update or after pulling new changes from the source reposiotry
: Re-run CMake using <code>rm -rf CMakeCache.txt && cmake -G Ninja ..</code>.
: The first command will delete cached and potentially stale info from the previous run, the second command will run CMake again to update the ninja files.
 
 
☎ ''If you can't solve your issue with the information above, please [https://inkscape.org/report report a bug] or [https://chat.inkscape.org/channel/team_devel\ ask in chat]''.
 
== Installing Build Dependencies Manually ==


If you are having trouble updating an existing, older MSYS2 installation, please uninstall MSYS2, remove the <code>C:\msys...</code> directories (remember to back up any data such as your MSYS-home-folder <code>C:\msys...\home\</code>), reboot and then start again.
'''Normally this is not needed.''' See "Install Dependencies Easily" above.


If neither of the above help, please [report a bug](https://inkscape.org/report) or [ask in chat](https://chat.inkscape.org/channel/team_devel).
For older versions before 1.5.0, or if you do not want the automatic installation, then you can also do all the installation steps by hand:
* '''Step 1''' &mdash; Install MSYS2
*# Download the installer from the [http://www.msys2.org/ MSYS2 homepage]  (a 64-bit version of Windows 7 or later is required to run MSYS2 and build Inkscape).<br />Start the installation and follow the instructions on screen. Use the standard installation directory <code>C:\msys64</code> .<br />Wait until it finishes.
*# Start an MSYS2 '''MSYS''' shell from the start menu (or launch "msys2.exe" in the installation directory).
*#Execute the command <code>pacman -Syuu</code>. This will start a full system upgrade and ensures that you have the latest versions of all core libraries.
*# Repeat the previous step until no new updates are found.
* '''Step 2''' &mdash; Download dependencies
*# Close the MSYS2 '''MSYS''' shell.
*#'''Read carefully:'''  Start an MSYS2 '''UCRT64''' (!!!) shell from the start menu (or launch "ucrt64.exe" in the installation directory). Using the right shell type is important that the correct dependencies are installed.
*#'''Double-check:''' The shell window must show "'''UCRT64'''" in purple text. If it shows "MSYS" then you have the wrong shell, please go back.
*# Execute the command <code>curl https://gitlab.com/inkscape/inkscape/-/raw/master/buildtools/msys2installdeps.sh | bash</code><br />(The command downloads and runs the script [https://gitlab.com/inkscape/inkscape/blob/master/buildtools/msys2installdeps.sh msys2installdeps.sh].  Alternatively, you can copy-paste the script into the console or download it, change to the folder containing the file and type <code>./msys2installdeps.sh</code>. If you already have a copy of the Inkscape source it should also be included in the "buildtools" folder.)
*# Relax and take a break, as this may take some time (a few minutes at best, but it can take significantly longer if you have a slow internet connection or the server load is high).
*'''Step 3''' - Install dependencies for creating the installer packages (.EXE, .MSI, .7Z)  This step is optional.
*#.7z: [http://www.7-zip.org/ 7-Zip].
*#.exe: [http://nsis.sourceforge.net/ Nullsoft Scriptable Install System (NSIS)] version 3 or later.
*#.msi:
*#*You'll need to install [http://wixtoolset.org/ Windows Installer XML (WiX Toolset)] version 4 (for Inkscape 1.4.1 and above). To install it:
*#**In the start menu, type <code>powershell</code> and click on "Run as Administrator"
*#**Open Notepad. Open the file buildtools/windows-deps-install-wix4.ps1 from the Inkscape sources. Select all. Copy.
*#**Click in the powershell window with the right mouse button to Paste and run the commands.
*#*For older versions up to 1.4.0, you will instead need WiX version 3 from https://github.com/wixtoolset/wix3/releases

Latest revision as of 16:26, 17 December 2024

This page explains how to compile Inkscape on Windows using MSYS2.

MSYS2 does not only offer a convenient build environment for compiling Inkscape but also provides all necessary build tools and dependencies making it extremely simple to get started with Inkscape development.

Installing Build Dependencies Easily

In the basic case, you can install all the needed tools with a one-click script. This is supported for Inkscape 1.5 or newer, running on standard 64bit Windows (not ARM). In other cases, please see below "Installing Build Dependencies Manually".

  1. Get the buildtools folder from the Inkscape git repository. One way to do this is the following:
  2. Double-click on windows-deps-clickHere.bat
    • If you get a warning "Windows protected your PC. Microsoft Defender prevented an unrecognized app from starting.", click on "More information" and "Run anyway".
    • Follow the instructions in the Terminal window. (Press Enter to confirm.)
    • Confirm Administrator rights if Windows asks you to
  3. Wait a few hours until the script says Done. Then you can compile Inkscape as described later.

Obtaining Inkscape Source

Note: For general instructions on how to use Git see Working with Git.

As MSYS2 provides the revision control software Git you do not need to download it separately.

Open the MSYS2 UCRT64 (!!!) shell from the start menu.

Run the command

git clone --recurse-submodules https://gitlab.com/inkscape/inkscape.git master

This creates a folder called "master" in the current working directory (usually the home folder located at "C:\msys64\home\Your_Username" or similar) in which the clone of the source repository is created.

You can later update it with:

git pull --recurse-submodules

Building Inkscape with MSYS2

  • Read carefully: To compile Inkscape open the MSYS2 UCRT64 (!!!) shell from the start menu (or launch C:\msys64\ucrt64.exe)
  • ⚠️ Warning: Using the right shell type is important so that the right type of Inkscape is built and the right dependencies are installed:
    • UCRT64 is the standard for compiling 64-bit Inkscape
    • (MinGW 64bit / 32bit was used until mid 2023 to build 64/32bit versions. ARM may be used in the future to build for ARM processors.)
    • Never use the "MSYS2 MSYS" shell for compiling Inkscape, only use it for updating MSYS2 itself.

Double-check: The shell window must show "UCRT64" in purple text. If it shows "MSYS" then you have the wrong shell.

Then execute the following commands:

# change to the directory containing your Inkscape source checkout (has to be
# adjusted to match your system)
cd master

# create a directory for the build (could also be another folder, but we'll
# assume 'build' being used for the rest of the article)
mkdir build
cd build

# create build files with CMake (we generate rules for "Ninja" as it's
# significantly faster then "MinGW Makefiles" which uses mingw32-make)
# note the source path '..' (which in this case is the parent directory) and
# should always point to the root folder of your copy of the Inkscape source
cmake -G Ninja ..

# start the compilation
ninja

# install compiled files and all dependencies required to run Inkscape into the
# folder 'build/inkscape/'
ninja install

# The last two steps can be combined (i.e. run 'ninja install' immediately) to
# save some time (the "install" target includes the default target)

That's it!
Afterwards you should have a complete binary distribution of Inkscape in the folder "build/inkscape/" that can be run on any machine running Windows 7 or later.

Running Inkscape

Simply execute inkscape.exe from the "build/inkscape/bin" directory (not "build/bin") created in the previous step. (The ninja install command takes care of copying all required files into this directory.)

Packaging

If you only want to run Inkscape you do not need to follow these instructions. See "Running Inkscape" above.

To package those files for distribution (to give it to other people, or make a setup file for other computers), you can use the following commands:

  • ninja dist-win-7z – generate binary 7z archive.
  • ninja dist-win-exe – generate .exe installer.
  • ninja dist-win-msi – generate .msi installer.
  • Additionally there's a dist-win-all target (executes all of the above in parallel).

For some additional details which have not been incorporated into this page yet see the previous instructions at Compiling Inkscape on Windows 32-bit#Creating an installer (might be partially oudated).

Troubleshooting

Issues with MSYS2

The MSYS2 shell does not open.
Try rebooting.

I have trouble updating an existing, older MSYS2 installation

  • Check https://www.msys2.org/news/ for any recent news that may describe your issue and explain how to solve it.
  • The most straightforward solution is often to re-install MSYS2:
    • Uninstall the old MSYS2. Make sure to completely remove the C:\msys64 directory if the uninstaller does not do the job but remember to back up any personal data such as your home folder C:\msys64\home\)
    • Download a fresh installer from https://www.msys2.org/ and start over as described above.

Issues with building Inkscape

The command `ninja` errors out after an MSYS2 update or after pulling new changes from the source reposiotry
Re-run CMake using rm -rf CMakeCache.txt && cmake -G Ninja ...
The first command will delete cached and potentially stale info from the previous run, the second command will run CMake again to update the ninja files.


If you can't solve your issue with the information above, please report a bug or ask in chat.

Installing Build Dependencies Manually

Normally this is not needed. See "Install Dependencies Easily" above.

For older versions before 1.5.0, or if you do not want the automatic installation, then you can also do all the installation steps by hand:

  • Step 1 — Install MSYS2
    1. Download the installer from the MSYS2 homepage (a 64-bit version of Windows 7 or later is required to run MSYS2 and build Inkscape).
      Start the installation and follow the instructions on screen. Use the standard installation directory C:\msys64 .
      Wait until it finishes.
    2. Start an MSYS2 MSYS shell from the start menu (or launch "msys2.exe" in the installation directory).
    3. Execute the command pacman -Syuu. This will start a full system upgrade and ensures that you have the latest versions of all core libraries.
    4. Repeat the previous step until no new updates are found.
  • Step 2 — Download dependencies
    1. Close the MSYS2 MSYS shell.
    2. Read carefully: Start an MSYS2 UCRT64 (!!!) shell from the start menu (or launch "ucrt64.exe" in the installation directory). Using the right shell type is important that the correct dependencies are installed.
    3. Double-check: The shell window must show "UCRT64" in purple text. If it shows "MSYS" then you have the wrong shell, please go back.
    4. Execute the command curl https://gitlab.com/inkscape/inkscape/-/raw/master/buildtools/msys2installdeps.sh | bash
      (The command downloads and runs the script msys2installdeps.sh. Alternatively, you can copy-paste the script into the console or download it, change to the folder containing the file and type ./msys2installdeps.sh. If you already have a copy of the Inkscape source it should also be included in the "buildtools" folder.)
    5. Relax and take a break, as this may take some time (a few minutes at best, but it can take significantly longer if you have a slow internet connection or the server load is high).
  • Step 3 - Install dependencies for creating the installer packages (.EXE, .MSI, .7Z) This step is optional.
    1. .7z: 7-Zip.
    2. .exe: Nullsoft Scriptable Install System (NSIS) version 3 or later.
    3. .msi:
      • You'll need to install Windows Installer XML (WiX Toolset) version 4 (for Inkscape 1.4.1 and above). To install it:
        • In the start menu, type powershell and click on "Run as Administrator"
        • Open Notepad. Open the file buildtools/windows-deps-install-wix4.ps1 from the Inkscape sources. Select all. Copy.
        • Click in the powershell window with the right mouse button to Paste and run the commands.
      • For older versions up to 1.4.0, you will instead need WiX version 3 from https://github.com/wixtoolset/wix3/releases