分享

只有472KB的minigtk.dll?这是怎么做到的?

 quasiceo 2013-02-14
只有472KB的minigtk.dll?这是怎么做到的?
一直不太原因选择pygtk的原因,一是控件不原生,二是windows下安装库太大,分发和维护都不方便

今天发现XChat for Windows很小(900多KB),而且用的是GTK。。。有一个472KB的minigtk.dll,就几乎实现了标准gtk的所有功能。。

这是怎么做到的呢?

有没有大牛编译一个for pygtk的兼容版本?


http:///files/source/2.8/?S=D
<http:///files/source/2.8/?S=D>别人把源代码都发出来了,还问什么啊,去翻吧。
2010/8/2


http:///files/binary/win32/mini-src/
<http:///files/binary/win32/mini-src/>minigtk可能是这里面的东西。
http://xc2free.9./index.php?showtopic=7
应该是编译教程吧?
<http://xc2free.9./index.php?showtopic=7>

源码是有。。。我想知道的是和官方8MB的库相比是怎么做到472KB而且不损失太多功能的。。。。

大小倒不是问题,QT虽然大,主要就两个dll:QtCore和QtGui,gtk带了一大堆文件,看着就晕,参考pidgin和tortoiseHg看看

在Qt里面,裁剪的原理就是把不用的
控件功能都去掉,最后只剩下几个基本的窗体,这么小还是有可能的。但是裁剪
程比较耗费时间的。 要仔细看编译文档和手册,熟悉类库的基本构架。当然,Qt
简化了这项工作,提供了一些工具来做。以前没有这个工具的时候,是写一个
config.h文件,在里面编辑一些定义的宏就可以完成基本的裁剪工作了

http://xc2free.9./index.php?showtopic=7

 This guide will tell you how to compie MiniGTK as a static library
and a shared DLL.

This was done with MS Visual C++ .NET 2003. I have not tried ti with
anythign else.

What you need:

MinGW - Get it here.
MS Visual C++ (edit by Pu7o: You can also use the free MSVC++ Toolkit,
available here. If you do, you should unzip this archive on the
toolkit's installation directory.)
MiniGTK Source Code - Get it here.
libiconv 1.9.2 Source Code - Get it here.
Cygwin - Get it here.

How:

First of all, extract glibgtkpango244.tar.bz2 with WinRAR or some
other archiving utility. Also, extract libiconv-1.9.2.tar.gz to the
same directory.

Open a Visual Studio Command Prompt windows and cd to the directory
where you extracted everything. Now, you have to set the PATH to you
cygwin and mingw bin directories.

For Example:
CODE
SET PATH=C:\MinGW\bin;C:\Cygwin\bin;%PATH%

The %PATH% is very important.

Now, cd to gtk\gtk. run nmake -f makefile.msc. Let it do its thing
until it finishes. The LIB file will automatically be moved to the
directory where you extracted everything.

Next, cd to ..\gdk\win32 and run nmake -f makefile.msc. Now, cd to ..
and run nmake -f makefile.msc. Once its done, ti will automatically
move teh LIB fiel to teh same directory as the gtk lib.

Now, copy libiconv-1.9.2\include\iconv.h.msvc-static to glib\glib and
rename it to iconv.h.

cd to the directory where you extracted everything. Then, cd to
glib/glib. Run nmake -f makefile.msc. It will eventualyl fail, and
complain about iconv.lib. Ignore this. cd to gnulib. Run nmake -f
makefile.msc. Now cd to .. and run nmake -f makefile.msc
glib-2.2s.lib. Copy glib-2.2s.lib to the same directory as teh otehr
libs you built.

Now, cd to ../gobject and run nmake -f makefile.msc. It will quickly
fail and give you anotehr iconv.lib thing. Ignore it. Now run nmake -f
makefile.msc gobject-2.2s.lib. Copy the lib to folder where you have
all of the rest of the libs.

Next, cd to ../gmodule. Run nmake -f makefile.msc. It will fail and
complain about glib. Ignore this. Run link -lib /out:gmodule-2.2s.lib
gmodule.obj. Copy the lib to the place with teh rest fo the libs you
built.

cd to ..\build\win32\dirent. Run nmake -f makefile.msc. Copy the lib
to the place with the rest fo the libs you built.

cd back to the directory where you extracted everything. Now, cd to
gtk\gdk-pixbuf. Run nmake -f makefile.msc. It will eventually fail and
complain abotu glib. Ignore it. Run nmake -f makefile.msc
gdk_pixbuf-2.2s.lib. Copy the lib to teh same directory as teh rest.

cd back to the directory where you extracted everything. Now, cd to
pango\pango and re-type "nmake -f makefile.msc". It will fail and
complain about glib. Ignore it. The libs you need have already been
build before the error occurred. Copy both libs to the directory with
teh rest of them.

cd back to the directory where you extracted everything. Now, cd to
libiconv-1.9.2.
Run:
CODE
sh configure --disable-shared --enable-static

Run make. Then, cd to lib\.libs and run teh following:

CODE
ar vx libiconv.a
link -lib /out:iconv.lib *.o

Copy the newly create lib file to teh same directory as the rest.

cd back to teh directory with all teh libs you built. In this
directory, create a file called empty.c and put this in it:

CODE
errno(){return 0;}
_alloca(){return 0;}

then run

CODE
gcc -c empty.c
lib -out:empty.lib empty.o
.

Now, edit makefile.msc so it looks like this:

CODE
OBJ = gobject-2.2s.lib gmodule-2.2s.lib glib-2.2s.lib  \
 gdk-win32-2.2s.lib gdk_pixbuf-2.2s.lib \
 pango-0.24s.lib pangowin32-0.24s.lib \
 gtk-win32-2.2s.lib dirent.lib empty.lib /nodefaultlib:libc.lib
LIBS = iconv.lib
SYSLIB = gdi32.lib shell32.lib user32.lib advapi32.lib imm32.lib
ole32.lib comdlg32.lib winmm.lib ws2_32.lib

all:
link /LTCG $(OBJ) /DLL /OUT:minigtk.dll /SUBSYSTEM:Windows $(LIBS)
$(SYSLIB) /DEF:minigtk.def
ls -l minigtk.dll
static:
link -lib $(OBJ) /OUT:minigtk-static.lib $(LIBS) $(SYSLIB)

Next, edit minigtk.def and remove the following from it

CODE
textdomain
gettext
bind_textdomain_codeset
bindtextdomain

To create minigtk.dll, run nmake -f makefile.msc.

To make the static library run nmake -f makefile.msc static. Ignore
the warnings.

To link it to xchat, use Pu7os guide.

If there are any errors in this guide, please post them.

EDIT by Pu7o: MinGW should be in the path first, not cygwin.

EDIT by Daemon404 : I have gotten gettext to work as a shared library.
Do This with cygwin, mingw, and msvc in your path:

Get the source code for gettext-0.10.40 (Must be that specific
version) and extract it.

cd to the directory and run sh configure --disable-shared
--enable-static and then run make. Find teh newly create libintl.a and
cd to intl\.libs and create a fiel named gettext.def with thsio in it:

CODE
EXPORTS
textdomain
gettext
bind_textdomain_codeset
bindtextdomain

Then run:

CODE
dllwrap --def gettext.def --dllname minintl.dll libintl.a

Refer to pu7o's guide abotu linkign to minigtk to fidn otu hwo to get
gettext.lib out of intl.dll using exports.sed. Then all you have to to
is add gettext.lib to the LIBS=... line of makefile.msc and have it in
the same dir as minigtk-static.lib, etc.

Edit by Pu7o: Changed "intl.dll" to "minintl.dll" for the following reason:

Intl.dll is the name used by the full gettext library. Using intl.dll
for this "miniature-version" of libintl could cause compatibility
problems with other programs which might use gettext.

Edit by Daemon404 (Again): I have been able to statically link my
minint to xchat using teh great program DLL to Lib by Binary-Soft. :-)

Edit by Pu7o: Added part about visual c++ toolkit, with the archive
zip file. The archive.zip file is based on this one by boing with some
extra needed files from the platform SDK. (a few .h files and
comdlg32.lib)

Edit by Pu7o: Changed links to reflect the new MiniGTK.

Edit by Daemon404. It is also possible to compile MiniGTK with MSVC
6.0. I just did it. You need to add /Zm1000 to the command line
arguments in makefile.msc in glib\glib

This post has been edited by Daemon404 on June 24, 2005 01:02 am

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多