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

From Inkscape Wiki
Jump to navigation Jump to search
(→‎Obtaining Inkscape Source: add warning about a pitfall with launchpad-login)
(Update for git and simplify some steps)
Line 8: Line 8:
* '''Step 1''' — Install MSYS2
* '''Step 1''' — 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]. Start the installation and follow the instructions on screen.
**After installation finished start an 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 -Syu</code>. This will start a full system upgrade and ensure that you have the latest versions of all core libraries (repeat this step until no new updates are found).
**Execute the command <code>pacman -Syu</code>. This will start a full system upgrade and ensure that you have the latest versions of all core libraries (repeat this step until no new updates are found).
* '''Step 2''' &mdash; Download dependencies
* '''Step 2''' &mdash; Download dependencies
** Start an MSYS shell (use the "MSYS2 MSYS" shortcut in the start menu or launch "msys2.exe" in the installation directory).
** 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.
** Execute the script [http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/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 checkout of Inkcape trunk it should also be included in the root folder.<br>You can optionally customize whether you want to download and install dependencies for 32-bit builds, 64-bit builds, or both (default). Please see the comments in the script for details.
** 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...


== Obtaining Inkscape Source ==
== Obtaining Inkscape Source ==


''Note: For general instructions on how to use Bazaar see [[Working with Bazaar]].''
''Note: For general instructions on how to use Git see [[Working with Git]].''


As MSYS2 provides the revision control software Bazaar you do not need to download it separately. Simply open an MSYS shell (use the "MSYS2 MSYS" shortcut in the start menu or launch "msys2.exe" in the installation directory) and run the command
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
<pre>bzr checkout lp:inkscape trunk</pre>
<pre>git clone https://gitlab.com/inkscape/inkscape.git master</pre>
This creates a folder called "trunk" in the current working directory (usually the home folder located at "C:\msys64\home\Your_Username" or similar) in which the checkout 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 so-called clone of the source repository is created.
 
''Warning: Do not set a "launchpad-login" in this step (even if Bazaar warns you) unless you know how to properly set-up an SSH client and how to create/use a public/private key pair. Unless you plan to push your work to a branch on Launchpad this is not required. OpenSSH is known to work fine once needed (download it with <code>pacman -S openssh</code>).''
 
''Note: MSYS2's Bazaar &ndash; as every Linux version of Bazaar being used on NTFS volumes &ndash; does not read actual file access rights from the file system (they're almost never correct anyway) but instead assumes reasonable defaults (specifically for the x-bit), see {{bug|id=248333}}. If you're seeing modified files (marked with an asterisk (*) in <code>bzr status</code> output) with otherwise unchanged content, this is why.''


== Building Inkscape with MSYS2 ==
== Building Inkscape with MSYS2 ==


To compile Inkscape open a MinGW shell (use the "MSYS2 MinGW 32/64-bit" shortcut in the start menu or launch "mingw32/64.exe"). The bitness of the shell will decide whether a 32-bit or a 64-bit version of Inkscape is built (obviously you have to match your decision with the bitness of the libraries you downloaded in Step 2 above).
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).


Then execute the following commands:
Then execute the following commands:
<pre>
<pre>
# change to the directory containing your Inkscape source checkout (has to be adjusted to match your system)
# change to the directory containing your Inkscape source checkout (has to be adjusted to match your system)
cd trunk
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)  
# create a directory for the build (could also be another folder, but we'll assume 'build' being used for the rest of the article)  
Line 41: Line 37:


# create build files with CMake (we generate rules for "Ninja" as it's significantly faster then "MinGW Makefiles" which uses mingw32-make)
# 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 Inkscape source checkout
# 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 ..
cmake -G Ninja ..


Line 47: Line 43:
ninja
ninja


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



Revision as of 01:13, 1 August 2017

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

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. 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 -Syu. This will start a full system upgrade and ensure that you have the latest versions of all core libraries (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...

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 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 so-called clone of the source repository is created.

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

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.