Contents

 

 

Getting Started with Inkscape Development

Code Link: https://gitlab.com/inkscape/inkscape

This is intended to be a quick reference to getting started with Inkscape development. For the details, take a look at the Inkscape Wiki and other specific documentation, and don't hesitate to ask in the chat or mailing list (see below). If you only want to test but not change the code, you can save time and download the prebuilt latest development version.

Setting up a GitLab account

To report bugs and help with technical subjects you will need a GitLab account. Detailed instructions for setting up an account are available in the Gitlab user tutorial.

Fetching the source code

The first step is to obtain the source code. Just downloading the "Release" source code files is not enough, as you will need to get the latest bleeding-edge sources in order to develop Inkscape.

Inkscape uses the git version control system. Platform-specific installation instructions are available here. On most Linux systems, you need to install the git package.

We recommend to set up a GitLab account (see above) before obtaining the source code, since that way it is easier to commit later once you get commit access. Once you set up your GitLab account, execute the following commands:

git config --global user.name "Real Name" 
git config --global user.email "e-mail@domain.tld"

where Real Name is your real name or a pseudonym you want to use (it should be recognizable to people on the mailing list) and e-mail@domain.tld is your e-mail for Inkscape-related correspondence (it can be obfuscated if you want - but the obfuscated email address must be added at gitlab as one of your email addresses, so your commits can be associated with your account). With this setup, you will be able to commit once you are approved as a member of the Inkscape Developers team on GitLab.

To obtain the latest source code, use the following command (downloads into a subdirectory of your current working directory called "inkscape" by default):

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

To update this code later, change into the download folder and use:

git pull --recurse-submodules && git submodule update

By default git will download every branch and every commit. If you are on a slow machine, have limited disk space or limited internet bandwidth, you can use shallow clone and single branch clone options to limit the amount of data it will download:

git clone --depth=1 --single-branch --recurse-submodules --shallow-submodule https://gitlab.com/inkscape/inkscape.git

Building Inkscape on Linux

Open a terminal at the root of the folder into which you downloaded the source code in the previous step.

Install build dependencies

Download and run the script to install everything required for compiling Inkscape (check script to see if your distribution is supported):

wget -v https://gitlab.com/inkscape/inkscape-ci-docker/-/raw/master/install_dependencies.sh -O install_dependencies.sh
bash install_dependencies.sh --recommended

Compile

To compile with CMake, do the following:

mkdir build
cd build
cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=${PWD}/install_dir -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
make -j8
make install

Notes:

  • Using ccache is optional but speeds up compilation.
  • It is possible to use the Ninja build system instead of Make, by adding the cmake argument -GNinja and replacing instances of make in the above commands with ninja.
  • The optional -j8 argument to make or ninja tells it to run 8 jobs in parallel. Feel free to adjust this to the number of hardware threads (physical cores) available on your computer.
  • The recommended -DCMAKE_INSTALL_PREFIX argument allows to specify a custom isolated installation location (in the example above install_dir/ inside the build folder). It avoids installation into system locations (where it could conflict with other versions of Inkscape) and allows running multiple versions of Inkscape in parallel. It will still use all the files (including the preferences.xml) that reside in the ~/.config/inkscape directory.
  • If you are using GCC or Clang, you might want to use the mold linker, as it can be considerably faster and is mostly a drop-in replacement. To do this, add to your cmake invocation the argument -DCMAKE_CXX_FLAGS="-fuse-ld=mold"

  • A tutorial to CMake is out of scope, but other cmake arguments that you may find useful include -DCMAKE_BUILD_TYPE=Debug and -DWITH_ASAN=ON, to facilitate debugging and (if your system's compiler supports it) to enable the Address Sanitizer to help diagnose bugs.

Run

Run it from the build directory:

install_dir/bin/inkscape

Test (optional)

To compile and run the test suite, use:

make check

Building Inkscape on Windows

The latest instructions are always available on the Inkscape Wiki, see Compiling Inkscape for Windows.

Building Inkscape on Mac

The latest instructions are always available on the Inkscape Wiki, see Compiling Inkscape for macOS.

Debugging with GDB

See Debugging Inkscape.

Inkscape Development

The Inkscape Codebase

Inkscape started as a fork of Sodipodi, a GNOME application based on GObject. Inkscape is written in a mixture of C and C++, due to historical reasons. We hope to eventually migrate it to C++. There is still however, a lot of GObject-based code, so some knowledge of GObject is necessary to work with Inkscape.

Inkscape uses the GTK+ widget toolkit and the Glib support library. We are in the process of migrating from GTK+ 2.0 to GTK+ 3.0 for the upcoming 1.0 release. We also use the header-only parts of Boost (i.e. it is a compile-time dependency, but not a runtime dependency). The geometry library lib2geom, written in C++, is intended to eventually become a separate project. You can get the latest version of lib2geom from its Gitlab repository.

Knowing how to program in C++, and use GTK is essential for contributing to Inkscape. Fortunately, these aren't that difficult to learn, so do read relevant tutorials.

The Inkscape project uses Doxygen to automatically generate source code documentation (including diagrams of the program structure). You can quickly get an overview about the part of the program you'd like to work on here.

Programming Style

Inkscape's programming style guidelines can be found here.

Community

Contributing Code

The above instructions show how to obtain Inkscape's source code and compile it. If you just want to look around or make some changes for your personal use only, this is a good starting point.

Once you have implemented new features or fixed bugs, you may want to contribute the changes back to the official Inkscape source code, such that other people can also benefit from your efforts. To do so, the recommended method is to send a merge request on GitLab so that developers can submit feedback on your changes.

The following sections are a rough guide to introduce you to the topic. They should get you started, but are no in-depth guide and provide only some indications of the required steps. If you are new to Git you will likely need to lookup some of the commands and terms on your own.

Creating a fork

A fork is your own copy of a GitLab repository on GitLab. Contrary to the official repository of Inkscape, you can push changes to your fork (you have write access) and thereby make them publicly available.

Create a fork by clicking the Fork icon in the upper right corner of Inkscape's main GitLab page. See the GitLab documentation on this topic for more information. You then work with your fork instead of the official repository, i.e. clone it to your local storage.

To keep your fork up to date with changes in the official Inkscape codebase you can enable the mirroring functionality of GitLab. Otherwise you won't see changes in the official codebase performed by other developers in your fork unless you update it manually.

Note: The mirroring functionality only transfers changes from the official Inkscape repository to your fork on GitLab. To update your local copy, you still have to run git pull to obtain the changes from GitLab.

Changes to CI settings

When you push changes, automatic builds and tests on the GitLab servers are initiated. The default timeout of GitLab is too short for the Inkscape build. See the GitLab documentation where to find it and change it to 3h.

Creating a branch

Merge requests operate on branches, so it necessary to create a new branch for the changes you want to contribute. Assume you are going to fix a nasty bug. Create a branch with an appropriate name, e.g., fix-for-bug-xyz, by running

git checkout -b fix-for-bug-xyz

on the local clone of your fork. Make your changes (the bugfix) and commit them.

Pushing changes

When you are done with your changes, it is usually a good idea to take a few moments and review the status of your local Git repository and your work to make sure everything is the way you want. Pushing the branch to your GitLab repository will make it publicly available.

To push the branch to your fork of Inkscape on GitLab, run

git push origin fix-for-bug-xyz

This also produces a notification like

remote: To create a merge request for fix-for-bug-xyz, visit:
remote:   https://gitlab.com/userxxx/inkscape/-/merge_requests/new?merge_request%5Bsource_branch%5D=fix-for-bug-xyz

with a link for creating a merge request (where userxxx is your username). This message is only output for newly created branches.

Creating a merge request

There are multiple ways to create a merge request. For example, you can use the above link printed by git push to create a merge request. Alternatively, you can select your branch on the GitLab web interface and click Create merge request in the upper right corner. See the GitLab documentation for more information on creating merge requests.

In GitLab's merge request form, enter a title, a meaningful description and attach files if appropriate.

It is recommended to tick the Allow commits from members who can merge to the target branch. checkbox. This allows the core developers to push changes directly to your branch and thereby simplifies the integration of your code into Inkscape.