我正在尝试在 OS X El Capitan 上安装 Perl 软件包 Math::GMP。
我有一台计算机可以正常工作 - 但第二台计算机遇到以下问题:
Perl 模块 Math::GMP 需要 GMP 的 C 库,所以我做了一个
brew install gmp
此安装的 GMP 包括以下文件:
/usr/local/include/gmp.h
但是软件包安装仍然失败,声称我没有安装 gmp:
$ sudo perl -MCPAN -e shell
cpan[1]> install Math::GMP
Reading '/Users/chaosadmin/.cpan/Metadata'
Database was generated on Sat, 14 Nov 2015 09:17:02 GMT
Running install for module 'Math::GMP'
Checksum for /Users/me/.cpan/sources/authors/id/S/SH/SHLOMIF/Math-GMP-2.11.tar.gz ok
Scanning cache /Users/me/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring S/SH/SHLOMIF/Math-GMP-2.11.tar.gz with Makefile.PL
Can't link/include C library 'gmp.h', 'gmp', aborting.
No 'Makefile' created SHLOMIF/Math-GMP-2.11.tar.gz
/usr/bin/perl Makefile.PL -- NOT OK
Failed during this command:
SHLOMIF/Math-GMP-2.11.tar.gz : writemakefile NO -- No 'Makefile' created
最明显的一行是:
Can't link/include C library 'gmp.h', 'gmp', aborting.
但我肯定已经安装了“gmp.h”
/usr/local/include/gmp.h
我不确定为什么它无法在这台 OS X El Capitan 机器上安装(它在我的另一台机器上运行良好)。
在我使用的 CPAN shell 中:
look Math::GMP
并更新了Makefile.PL以进行调试:
check_lib_or_exit(
header => 'gmp.h',
lib => 'gmp',
debug => 'true'
);
运行时显示以下错误
perl Makefile.PL
# /usr/bin/cc -arch i386 -arch x86_64 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -arch i386 -arch x86_64 -fstack-protector assertlibD4RJzZEa.c -o assertlibwGFzIVsM
assertlibD4RJzZEa.c:1:10: fatal error: 'gmp.h' file not found
对于仍在寻找答案的人,我可以通过执行以下操作将 Math::BigInt::GMP 安装在 Sonoma 14.1.2 上:
brew install gmp
# possibly ADD TO ~/,bashrc, can export from cmd line
export CPATH=/opt/homebrew/include:$LD_LIBRARY_PATH
export CPATH=`xcrun --show-sdk-path`/opt/homebrew/include:$CPATH
这也解决了我在 openssl 和其他一些软件包中遇到的一些相关安装解析问题。我前段时间在某个地方找到了这个并记录下来。在新 Mac 上安装时,我翻出了我的笔记。如果我找到原始资料,我会再次更新这个僵尸问题。
在 Centos 上:
只需安装这个: yum install gmp* -y
祝你好运:)