2016-09-25 183 views
2

我想安裝perl Gtk2,爲此我需要首先安裝Glib。我試過sudo cpanm Glib,但編譯時出現錯誤(我也嘗試下載.tar.gz源文件等,具有相同的效果)。我也嘗試過一個老版本的Glib。我在OS X 10.11(El Capitan)上。這裏的錯誤:無法在OS X上安裝Perl模塊Glib(El Capitan)

error: '_GStaticAssertCompileTimeAssertion_0' declared as an array with a negative size 

我不知道如何解決它...非常感謝,如果任何人都可以爲我做點事情! (順便說一句,brew install glib工作正常,但它似乎是我試圖構建和運行的應用程序 - 例如自動多項選擇)正在尋找Gtk2.pm,因此,Homebrew安裝的「glib」沒有幫助。)

Benjamin

p.-s. :下面是完整的日誌,如果有幫助:

cpanm (App::cpanminus) 1.7042 on perl 5.018002 built for darwin-thread-multi-2level 
Work directory is /Users/benjamin/.cpanm/work/1474765262.7331 
You have make /usr/bin/make 
You have LWP 6.05 
You have /usr/bin/tar: bsdtar 2.8.3 - libarchive 2.8.3 
You have /usr/bin/unzip 
Searching Glib() on cpanmetadb ... 
--> Working on Glib 
Fetching http://www.cpan.org/authors/id/X/XA/XAOC/Glib-1.322.tar.gz 
-> OK 
Unpacking Glib-1.322.tar.gz 
Entering Glib-1.322 
Checking configure dependencies from META.json 
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (6.66) 
Checking if you have ExtUtils::PkgConfig 1.000 ... Yes (1.15) 
Checking if you have ExtUtils::Depends 0.300 ... Yes (0.306) 
Configuring Glib-1.322 
Running Makefile.PL 
Including generated API documentation... 
Checking if your kit is complete... 
Looks good 
Writing Makefile for Glib 
Writing MYMETA.yml and MYMETA.json 
-> OK 
Checking dependencies from MYMETA.json ... 
Checking if you have ExtUtils::Depends 0.300 ... Yes (0.306) 
Checking if you have ExtUtils::PkgConfig 1.000 ... Yes (1.15) 
Checking if you have ExtUtils::MakeMaker 0 ... Yes (6.66) 
Building and testing Glib-1.322 
cp lib/Glib/CodeGen.pm blib/lib/Glib/CodeGen.pm 
cp /Users/benjamin/.cpanm/work/1474765262.7331/Glib-1.322/typemap blib/arch/Glib/Install/typemap 
cp lib/Glib/ParseXSDoc.pm blib/lib/Glib/ParseXSDoc.pm 
cp doctypes blib/arch/Glib/Install/doctypes 
cp devel.pod blib/lib/Glib/devel.pod 
cp gperl_marshal.h blib/arch/Glib/Install/gperl_marshal.h 
cp lib/Glib/MakeHelper.pm blib/lib/Glib/MakeHelper.pm 
cp gperl.h blib/arch/Glib/Install/gperl.h 
cp lib/Glib.pm blib/lib/Glib.pm 
cp lib/Glib/Object/Subclass.pm blib/lib/Glib/Object/Subclass.pm 
cp build/IFiles.pm blib/arch/Glib/Install/Files.pm 
cp lib/Glib/GenPod.pm blib/lib/Glib/GenPod.pm 
[ XS Glib.xs ] 
[ CC Glib.c ] 
In file included from Glib.xs:22: 
In file included from ./gperl.h:37: 
In file included from /usr/local/Cellar/glib/2.48.2/include/glib-2.0/glib-object.h:23: 
In file included from /usr/local/Cellar/glib/2.48.2/include/glib-2.0/gobject/gbinding.h:28: 
In file included from /usr/local/Cellar/glib/2.48.2/include/glib-2.0/glib.h:30: 
In file included from /usr/local/Cellar/glib/2.48.2/include/glib-2.0/glib/galloca.h:32: 
/usr/local/Cellar/glib/2.48.2/include/glib-2.0/glib/gtypes.h:422:3: error: '_GStaticAssertCompileTimeAssertion_0' declared as an array with a negative size 
    G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64)); 
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
/usr/local/Cellar/glib/2.48.2/include/glib-2.0/glib/gmacros.h:232:103: note: expanded from macro 'G_STATIC_ASSERT' 
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED 
                             ^~~~~~~~~~~~~~~ 
1 error generated. 
make: *** [Glib.o] Error 1 
-> FAIL Installing Glib failed. See 
/Users/benjamin/.cpanm/work/1474765262.7331/build.log for details. Retry with --force to force install it. 
+0

這個在10.11.6使用glib2 @ 2.48.2從[MacPorts](https://www.macports.org/)與perlbrew安裝的Perl 5.20.2編譯得很好。 MacPorts版本[有補丁](https://trac.macports.org/browser/trunk/dports/devel/glib2/files),可能HomeBrew沒有。 – Schwern

+0

感謝您的回答。在更新perl(5.24.0通過perlbrew)之後,我終於成功構建了Glib!不幸的是,現在它是Gtk2,不會編譯...! –

+0

圖形庫和Perl是臭名昭着的。但它爲我工作!™再次使用來自MacPorts的gtk2 @ 2.24.31與來自Perlbrew的5.20.2。 MacPorts還提供了一個Gtk2.pm包(p5-gtk2)。你可能想備份到Perl 5.20或5.22,讓模塊修復5.24引起的任何問題。 – Schwern

回答

3

這被派往GitHub issue

我通過運行找到了問題所在:

cpanm --verbose --build-args=NOECHO=' ' Glib

,這樣我可以看到失敗的特定編譯命令:

cc -c -I. -I/usr/local/Cellar/glib/2.50.0/include/glib-2.0 -I/usr/local/Cellar/glib/2.50.0/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.39/include -D_REENTRANT -arch x86_64 -arch i386 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -Os -DVERSION=\"1.323\" -DXS_VERSION=\"1.323\" -o Glib.o "-I/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE" Glib.c

既然問題是事做不匹配sizeof's,我認爲問題在於Perl構建的體系結構不是Homebrew的libglib-2.0的體系結構b反對。

解決方法是指定通過設置ARCHFLAGS環境變量,你只需要建立x86_64

ARCHFLAGS="-arch x86_64" cpanm --verbose Glib

這是所有使用該系統的Perl。如果您希望安裝在系統升級過程中長期運行,您將需要使用perlbrew或plenv來安裝自己的用戶Perl。

+0

感謝您的幫助!在我通過perlbrew安裝了一個新的Perl之後,Glib現在正在建設中。不幸的是,我仍然無法構建Gtk2 ... –

+0

'ARCHFLAGS =「 - arch x86_64」'幫助我安裝Ruby glib2 gem。 – Nakilon

-1

我遇到了同樣的問題。

安裝gtk +作爲先決條件修復它。

+0

感謝您的回答,但那會導致不同的錯誤。 – Schwern

相關問題