macos - 无法在 OS X (El Capitan) 上安装 perl 模块 Glib

标签 macos perl glib

我想安装 perl Gtk2,为此我需要首先安装 Glib。我尝试了 sudo cpanm Glib ,但编译时出现错误(我也尝试下载 .tar.gz 源等,效果相同)。我还尝试过旧版本的 Glib。我使用的是 OS X 10.11 (El Capitan)。这是错误:

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

我不知道如何解决这个问题...如果有人能为我做点什么,非常感谢! (顺便说一句,brew install glib 工作正常,但我试图构建和运行的应用程序(例如自动多项选择)似乎正在某处寻找 Gtk2.pm。所以,Homebrew 安装的 'glib' 没有任何帮助。)

本杰明

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.

最佳答案

此内容已发布到 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 不匹配有关,我认为问题在于 Perl 构建所使用的体系结构与 Homebrew 的 libglib-2.0 构建所针对的体系结构不同。

修复方法是通过设置 ARCHFLAGS 环境变量来指定您只想针对 x86_64 进行构建:

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

这都是使用系统Perl。如果您希望安装在系统升级后长期运行,您将需要使用 perlbrew 或 pleenv 安装您自己的用户 Perl。

关于macos - 无法在 OS X (El Capitan) 上安装 perl 模块 Glib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39686986/

相关文章:

macos - iTerm 中的 Bash 键盘快捷键,例如 Alt+d 和 Alt+f

multithreading - 线程 : worth it for this situation?

perl - 如何使用 CGI::Application 获取上传文件的内容类型?

mysql - 如何在 MySQL 中查询包含亚洲语言字符的文本?

c++ - 使用 libfm Linux 在 C 中自定义操作或命令?

c - g_hash_table_insert malloc() : memory corruption

objective-c - 上下文菜单中的自定义条目

python - “SSL: CERTIFICATE_VERIFY_FAILED” mac 错误

ios - 使用 libusbmuxd 在 Mac 和 iPhone 之间读/写

c - 打开和关闭日志文件会导致 C 中的内存泄漏