Building from sources

Calle Laakkonen edited this page Feb 16, 2017 · 17 revisions

Building Drawpile

To compile the client, you will need:

  • Qt 5 development libraries
  • These KDE Frameworks 5 libraries:
    • KArchive (bundled, but use external library if possible)
    • KDNSSD (optional, enables local server discovery)
  • GIFLIB (optional, enables animated GIF export)
  • QtColorPicker (bundled, but external library is used if available)
  • MiniUPnP client library (optional, enables automatic port forwarding)
  • cmake
  • g++, clang or Visual Studio (community edition)

After the dependencies are installed (see below for instructions), Drawpile can be built the same way on all platforms.

Building with Qt Creator

Open the root CMakeLists.txt file with Qt Creator and press Build.

When building with MSVC, the machine type might not be set correctly (Qt creator bug?). If this happens, try running cmake from the VS command line.

Building from the command line

Create a build directory and run cmake there:

mkdir build
cd build
cmake ..

If Qt was not installed as a system library, you may need to tell CMake where to find it. For example:

cmake .. -DCMAKE_PREFIX_PATH=~/Qt/5.4/clang_64

Some useful cmake arguments you can use:

  • -DCLIENT=off: Compile only the server
  • -DTOOLS=on: Compile additional tools (dprect2txt, txt2dprec)
  • -DCMAKE_BUILD_TYPE=debug: Compile a debugging version
  • -DINITSYS=systemd: enable systemd socket activation and logging support for the dedicated server

Installing dependencies

Linux dependencies

Install the dependencies using the distribution's package manager:

  • Arch Linux: pacman -S qt5-base cmake gcc karchive kdnssd giflib miniupnpc
  • Debian stable: apt-get install qtbase5-dev libgif-dev cmake g++ (note. karchive and kdnssd are not packaged in debian 8 stable)
  • Ubuntu 14.04: apt-get install qtbase5-dev qtmultimedia5-dev libqt5svg5-dev libminiupnpc-dev libgif-dev cmake qttools5-dev qttools5-dev-tools (karchive is not packaged in ubuntu 14.04.) You can get kdnssd by install kdelibs5-dev but that will pull in a lot of packages.
  • Ubuntu 16.04: same as above, but libkf5archive-dev libkf5dnssd-dev are available (note: Qt version is 5.5)

Windows dependencies (MinGW)


  • Install Qt Creator, MinGW and the latest Qt version using the online installer from
  • Install cmake
  • Add gcc and cmake binary directories to your PATH environment variable

For convenience when building the dependencies, set the variable QTPATH to point to your Qt installation:

SET QTPATH=C:\qt\5.7\mingw53_32

Next, download the sources for the required KF5 libraries.


This is needed to build KArchive and other KF5 modules. Drawpile itself does not use it.

Unpack cmake-extra-modules, open the command prompt and execute:

cd (path to ecm)
cmake . -DCMAKE_INSTALL_PREFIX=%QTPATH% -G "MinGW Makefiles"
mingw32-make install


After installing ecm, you can build karchive:

cd (path to karchive)
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=%QTPATH% -DCMAKE_PREFIX_PATH=$QTPATH -G "MinGW Makefiles" -DZLIB_LIBRARY:FILEPATH=C:\Qt\tools\mingw530_32\lib\libz.a
mingw32-make install

When deploying, remember to copy the libkarchive DLL from the build/bin directory to Drawpile's folder!


(This one is optional. If left out, the local server discovery feature will not be enabled.)

Install Bonjour SDK for Windows

First, we must convert the MSVC library to a GCC compatible one. These instructions are based on the answer to this stackoverflow question:

You need the reimp command, which is part of MinGW utils (Note. Version 0.4-1 gave me a "invalid or corrupt import library error" but 0.3 version worked. This one also seems to work:

You need the following files: dnssd.lib (from Bonjour SDK\Lib\Win32), dnssd.dll (from c:\windows\system32) and dnssd.h (from Bonjour SDK\include)

Copy the libraries to somewhere where you have write access and run:

reimp dnssd.lib

This will produce a file named DLLStub.obj. Next, run:

gendef dnssd.dll

Assemble the .a file:

dlltool -k -d dnssd.def -l libdns_sd.a

Copy libdns_sd.a to MinGW's library path (e.g. your Qt installation's lib directory.)

Before compiling KDNSSD, the following changes must be made:

src/mdnssd-remoteservice.cpp:  replace #include <netinet/in.h> with #include <Winsock2.h>
                               add DNSSD_API to domain_callback declaration

src/mdnssd-publicservice.cpp:  replace #include <netinet/in.h> with #include <Winsock2.h>
                               add DNSSD_API to publish_callback declaration

src/mdnssd-servicebrowser.cpp: add DNSSD_API to query_callback declaration

src/CMakeLists.txt:            add ws2_32 to target_link_libraries


mkdir build
cd build
mingw32-make install

(Replace $BONJOURSDK_INCLUDE_DIR with the path to the include directory of the Bonjour SDK installation.)

For some reason, cmake complains about missing DNSServiceRefDeallocate. I haven't yet figured out how to fix it properly, but you can bypass it by taking out the DNSSD_FUNCTION_FOUND check from FindDNSSD.cmake

As with karchive, remember to copy the DLL file from build/bin to the deployment folder!


Building GIFLIB the right way requires a full MSYS install since it uses autotools as the build system. Luckily, it is very simple to build manually.

Unpack the archive, open a command shell and run:

cd lib
gcc -c *.c
ar rcs libgif.a *.o

Copy libgif.a to mingw's library directory and gif_lib.h to the include directory.


Unpack miniupnpc and run mingw32make.bat

Copy libminiupnpc.a to Qt's lib directory and all the .h files to a directory named miniupnpc under Qt's include directory.

Windows dependencies (Visual Studio)

Note: currently the official Drawpile package is built with 32 bit mingw, but I may switch to 64bit MSVC for future versions (2.0 and later).


  • Install Visual Studio (free community edition works fine)
  • Install Qt Creator, and the latest Qt version using the online installer from
  • Install cmake
  • Add cmake binary directory to your PATH environment variable

Download the source code for the dependecies.

Launch Visual Studio Command Prompt from the Tools menu. Enable 64 bit mode by entering:

cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
vcvarsall amd64

%QTPATH% is the path to your (compiler specific) Qt installation.


cd (path to ecm)
cmake . -DCMAKE_INSTALL_PREFIX=%QTPATH% -G "NMake Makefiles"
nmake install


Unpack zlib sources and run:

nmake /f win32/Makefile.msc
copy zlib.lib %QTPATH%/lib
copy zlib.h %QTPATH%/include
copy zconf.h %QTPATH%/include


nmake install


TODO (should be easier since there is no need to convert library types)





OSX dependencies

Install Xcode and Xcode command line tools to get the C++ compiler. Install cmake (e.g. from MacPorts)

Download the source code to the latest KF5 frameworks.

$QTPATH is the path to the Qt installation, e.g. QTPATH=~/Qt/5.4/clang_64.

First, install extra-cmake-modules:

$ tar xfvz extra-cmake-modules-5.9.0.tar.xz
$ cd extra-cmake-modules-5.9.0
$ make
$ make install

Next, install karchive:

$ tar xfvz karchive-5.9.0.tar.xz
$ cd karchive-5.9.0
$ mkdir build
$ cd build
$ make
$ make install

Note. To maintain compatibility with OSX 10.8, remove LZMA support. (Just remove the lines that search for that library in CMakeLists.txt)

KDNSSD is installed in the same way as KArchive.

Unpack GIFLIB sources and compile:

$ ./configure --prefix=$QTPATH
$ make
$ make install

Unpack miniupnpc and install: