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

From Inkscape Wiki
Jump to navigation Jump to search
(→‎Installing MSYS2: recommend "uu" (i.e. also downgrade if necessary))
(→‎Installing MSYS2: add screenshots to help reduce 32-bit vs 64-bit confusion)
Line 4: Line 4:


== Installing MSYS2 ==
== Installing MSYS2 ==
[[File:MSYS2 installer labelled.png|600px|thumb|Install MSYS2 '''64'''-bit (aka '''''x86_64'''''). Only use MSYS2 32-bit (aka ''i686'') if you have a 32-bit OS]]
[[File:MSYS2 shells.png|600px|thumb|
<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:
To set-up MSYS2 and download the necessary dependencies only two steps are required:
* '''Step 1''' &mdash; Install MSYS2
* '''Step 1''' &mdash; Install MSYS2
** Download the installer from the [http://www.msys2.org/ MSYS2 homepage]. Start the installation and follow the instructions on screen.
** Download the installer from the [http://www.msys2.org/ MSYS2 homepage] (The MSYS2 64-bit version is recommended on a 64-bit OS, see screenshot to the right. Both versions can compile 32-bit and 64-bit versions of Inkscape). Start the installation and follow the instructions on screen.
**After installation finished 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).
**After installation finished 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).
**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 (make sure to repeat this step until no new updates are found).
**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 (make sure to repeat this step until no new updates are found).
Line 14: Line 27:
** Execute the script [https://gitlab.com/inkscape/inkscape/blob/master/buildtools/msys2installdeps.sh msys2installdeps.sh] by either copy-and-pasting it into the console or by downloading it and (after changing to the folder containing the file) typing <code>./msys2installdeps.sh</code>. If you already have a copy of the Inkscape source it should also be included in the "buildtools" folder.
** Execute the script [https://gitlab.com/inkscape/inkscape/blob/master/buildtools/msys2installdeps.sh msys2installdeps.sh] by either copy-and-pasting it into the console or by downloading it and (after changing to the folder containing the file) typing <code>./msys2installdeps.sh</code>. If you already have a copy of the Inkscape source it should also be included in the "buildtools" folder.
Step 2 will take some time to complete (approx. 10 minutes depending on the speed of your internet connection and the load of the download servers), so relax and get a cup of coffee...
Step 2 will take some time to complete (approx. 10 minutes depending on the speed of your internet connection and the load of the download servers), so relax and get a cup of coffee...
⚠️ ''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 ==
== Obtaining Inkscape Source ==

Revision as of 23:01, 11 June 2019

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 MSYS2

Install MSYS2 64-bit (aka x86_64). Only use MSYS2 32-bit (aka i686) if you have a 32-bit OS
Always use the proper shell
  • "MinGW 32-bit" for compiling 32-bit Inkscape
  • "MinGW 64-bit" for compiling 64-bit Inkscape
  • Never use the "MSYS" shell for compiling Inkscape, only use it for updating MSYS2 itself.

You can identify the different shells according to the the purple text string in the console window (MINGW32, MINGW64 or MSYS respectively).

To set-up MSYS2 and download the necessary dependencies only two steps are required:

  • Step 1 — Install MSYS2
    • Download the installer from the MSYS2 homepage (The MSYS2 64-bit version is recommended on a 64-bit OS, see screenshot to the right. Both versions can compile 32-bit and 64-bit versions of Inkscape). Start the installation and follow the instructions on screen.
    • After installation finished 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).
    • Execute the command pacman -Syuu. This will start a full system upgrade and ensures that you have the latest versions of all core libraries (make sure to repeat this step until no new updates are found).
  • Step 2 — Download dependencies
    • 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).
      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.
    • Execute the script msys2installdeps.sh by either copy-and-pasting it into the console or by downloading it and (after changing to the folder containing the file) typing ./msys2installdeps.sh. If you already have a copy of the Inkscape source it should also be included in the "buildtools" folder.

Step 2 will take some time to complete (approx. 10 minutes depending on the speed of your internet connection and the load of the download servers), so relax and get a cup of coffee...


⚠️ 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

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. Simply open the MSYS2 MinGW shell and 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

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).

An error message like `c:msys64mingw32bingcc.exe comand not found` could indicate that you should retry with the 64-bit version of MSYS2.

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) if you want to save time in future, as the "install" target also 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 Windows machine.

Packaging

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

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:

  • ninja dist-win-7z – generate binary 7z archive. You'll need to install 7-Zip.
  • ninja dist-win-exe – generate .exe installer. You'll need to install Nullsoft Scriptable Install System (NSIS) version 3 or later.
  • ninja dist-win-msi – generate .msi installer. You'll need to install Windows Installer XML (WiX Toolset).
  • Additionally there's a dist-win-all target (executes all of the above in parallel) and for each of the three there's also a dist-win-*-fast target (which is identical in functionality but will use a faster compression method which will increase package size but will also significantly reduce packaging time which can be useful for debugging/development purposes).

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).