How to distribute a GTK+ application on Windows?

You have some hints on the Windows page of the GTK website. This is the section named Building and distributing your application. It features a blog post about distributing a GTK application on Windows.

The solution proposed there is to create a MSYS2 package for your application, and then install it and all its dependencies (GTK among them) in a specific directory, so that you can redistribute the whole package.

2020-12-09 EDIT:

Reading the other answers, I want to add that this method not only gets the dependencies for shared objects and binaries right, but that should also work with other kinds of ressources (images, help files, etc.) that are in the required packages, as well as shared objects loaded at runtime with dlopen-based functions. This is something you can't get with just calling ldd to find the dependencies.


It turns out that running ldd mygtkapp.exe (with the ldd provided with MinGW) gave me a listing of all the dlls required to let it run. To get only the dlls which were gtk dependencies (and not e.g. Win32 dlls) I used the following command: ldd mygtkapp.exe | sed -n 's/\([^ ]*\) => \/mingw.*/\1/p' | sort. My program used the Haskell bindings, so the dependencies might be a bit different, but this is what I got:

libatk-1.0-0.dll
libbz2-1.dll
libcairo-2.dll
libcairo-gobject-2.dll
libepoxy-0.dll
libexpat-1.dll
libffi-6.dll
libfontconfig-1.dll
libfreetype-6.dll
libgcc_s_seh-1.dll
libgdk_pixbuf-2.0-0.dll
libgdk-3-0.dll
libgio-2.0-0.dll
libglib-2.0-0.dll
libgmodule-2.0-0.dll
libgobject-2.0-0.dll
libgraphite2.dll
libgthread-2.0-0.dll
libgtk-3-0.dll
libharfbuzz-0.dll
libiconv-2.dll
libintl-8.dll
libpango-1.0-0.dll
libpangocairo-1.0-0.dll
libpangoft2-1.0-0.dll
libpangowin32-1.0-0.dll
libpcre-1.dll
libpixman-1-0.dll
libpixman-1-0.dll
libpng16-16.dll
libstdc++-6.dll
libwinpthread-1.dll
zlib1.dll

Note also that there are a couple of other things you need to do to make a completely standalone application, particularly if you're using stock icons; for more details on this, see https://stackoverflow.com/a/34673860/7345298. Note however that I needed to copy the 16x16 directory instead of the scalable directory.

EDIT: I've actually found the following command to be very useful as well: ldd mygtkapp.exe | grep '\/mingw.*\.dll' -o | xargs -I{} cp "{}" .. This command actually copies the dlls to the current directory obviating the need to laboriously do it yourself.


The following procedure can be used to obtain the necessary DLLs:

  1. Download Listdlls
  2. Leave your application running
  3. Open the PowerShell window where Listdlls.exe is located
  4. Use the command ./Listdlls.exe application_name.exe
  5. Copy all listed paths to a text file
  6. Delete all lines that contain "C:\WINDOWS*" in your text file
  7. Leave only the lines that contain "C:\msys64*...*.dll" in your text file
  8. Open Msys2 Shell
  9. Use $ cp "paste_all_paths_from_dlls" "destination_path"

Cautions before using the $ cp command. In your text file, change "\" to "/" in the paths and remove line breaks.