如何在Windows上分发GTK +应用程序? [英] How to distribute a GTK+ application on Windows?
问题描述
我已经在Windows上通过MSYS和MinGW安装了GTK +(特别是GTK3).现在,我想将GTK + dll复制到我的应用程序目录中,这样它就可以在没有全局安装GTK +的计算机上运行. GTK +要运行哪些dll?
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?
GTK +文档现在包含说明,用于在Windows上分发所需的图标和主题. (尽管它没有有关分发相关DLL文件的说明-有关该说明,请参见下面的答案.)
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.)
推荐答案
事实证明,运行ldd mygtkapp.exe
(以及MinGW附带的ldd
)为我列出了使其运行所需的所有dll.为了只获取与gtk相关的dll(而不是例如Win32 dll),我使用了以下命令:ldd mygtkapp.exe | sed -n 's/\([^ ]*\) => \/mingw.*/\1/p' | sort
.我的程序使用了Haskell绑定,因此依赖关系可能有所不同,但这就是我得到的:
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
还请注意,制作一个完全独立的应用程序还需要做其他几件事,尤其是在使用股票图标的情况下;有关更多详细信息,请参见 https://stackoverflow.com/a/34673860/7345298 .但是请注意,我需要复制16x16目录而不是可伸缩目录.
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.
编辑:实际上,我还发现以下命令也非常有用:ldd mygtkapp.exe | grep '\/mingw.*\.dll' -o | xargs -I{} cp "{}" .
.该命令实际上将dll复制到当前目录,从而无需您自己费力地进行操作.
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.
这篇关于如何在Windows上分发GTK +应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!