Monday, November 19, 2007

Cygwin 环境下安装 Gtk2

这里的 Gtk2 是指 Perl 的 Gtk2 模块,Cygwin 环境下通过 CPAN 是无法直接安装的,需要修改了 Makefile.PL 之后手动安装。
--- Makefile.PL 2006/11/06 00:35:44 1.1
+++ Makefile.PL 2006/11/06 10:24:38
@@ -331,10 +331,6 @@

# this probably needs to go into ExtUtils::Depends.
sub find_extra_libs {
- # right now we need this terrible hack only for windows.
- # unfortunately, this code doesn't work on cygwin. :-/
- return "" unless $^O eq "MSWin32";
-
# win32 does not allow unresolved symbols in libraries, but
# Gtk2 uses on symbols in the dll created for Glib.
# so, we have to break all this nice abstraction and encapsulation
@@ -346,10 +342,19 @@
my $retstring = "";

use File::Find;
- find (sub {
- $retstring .= " ".$File::Find::name
- if /Glib.lib/i;
- }, @INC);
+
+ if ($^O eq "MSWin32") {
+ find (sub {
+ $retstring .= " ".$File::Find::name
+ if /Glib\.lib/i;
+ }, @INC);
+ } elsif ($^O eq "cygwin") {
+ find (sub {
+ $retstring .= " -L".$File::Find::dir
+ if /libGlib\.dll\.a/i;
+ }, @INC);
+ $retstring .= " -lGlib.dll" if ($retstring ne "");
+ }

return $retstring;
}

这是 Dirk Froemberg 向 Torsten Schoenfeld 提交的 patch,到现在为止还没有被合并进 source。

参考链接:
http://bugzilla.gnome.org

No comments: