Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distribute a GTK+ application on Windows?

I have installed GTK+ (specifically GTK3) via MSYS and MinGW on Windows. I now want to copy the GTK+ dlls to my application directory so that it can be run on a computer without a global GTK+ installation. Which dlls are required for GTK+ to operate?

EDIT: The GTK+ documentation now contains instructions for distributing the required icons and themes on Windows. (Although it doesn’t have instructions for distributing the relevant DLL files — for that see the answers below.)

like image 205
bradrn Avatar asked Mar 04 '18 06:03

bradrn


People also ask

Can you run GTK apps on Windows?

GTK# for . NET can be installed on Windows with the GTK# Installer. Follow these instructions to add a GTK# app that will run on the Windows desktop: In Visual Studio 2019, right-click on the solution name in Solution Explorer and choose Add > New Project....


1 Answers

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.

like image 198
bradrn Avatar answered Sep 26 '22 00:09

bradrn