为什么Nettle 2.4的`configure`找不到GMP 5.0.2?

时间:2011-11-01 11:53:32

标签: macos gnu configure ssl gmp

我正在尝试在Mac OS X 10.5(Leopard)服务器上构建GnuTLS(是的,我知道,它有点过时,但这就是此服务器正在运行的内容)并且遇到了问题建设Nettle:我已经建立了&已安装GMP,但Nettle的configure无法找到它。

我建造了&按如下方式安装GMP 5.0.2(GCC版本解决方案来自here):

curl -O ftp://ftp.gmplib.org/pub/gmp-5.0.2/gmp-5.0.2.tar.bz2
tar xjf gmp-5.0.2.tar.bz2
pushd gmp-5.0.2
CC=gcc-4.2 CXX=g++4.2 ./configure --prefix=/usr/local
make
sudo make install
popd

make check通过了所有测试,我最终安装了以下GMP文件:

/usr/local/include/gmp.h
/usr/local/lib/libgmp.10.dylib
/usr/local/lib/libgmp.a
/usr/local/lib/libgmp.dylib
/usr/local/lib/libgmp.la
/usr/local/share/info/gmp.info
/usr/local/share/info/gmp.info-1
/usr/local/share/info/gmp.info-2

但是,当我尝试构建Nettle 2.4时,如下所示:

curl -O http://www.lysator.liu.se/~nisse/archive/nettle-2.4.tar.gz
tar xzf nettle-2.4.tar.gz
pushd nettle-2.4
./configure --prefix=/usr/local
make
sudo make install
popd

它构建&安装成功,但由于缺少GMP,因此无法构建libhogweed。经过进一步检查,我在configure输出中发现了以下警告:

checking for __gmpz_getlimbn in -lgmp... no
configure: WARNING: GNU MP not found, or not 3.1 or up, see http://gmplib.org/.
Support for public key algorithms will be unavailable.
checking for __gmpz_powm_sec... no

显然,GMP 5.0.2比3.1更新,再加上'__gmpz_getlimbn'和& '__gmpz_powm_sec'在/usr/local/include/gmp.h中定义,因此我的GMP安装的所有内容都是正确的。

我尝试了各种configure选项(尤其是寻找某种类型的'--with-gmp'选项)无济于事。我也尝试使用与编译GMP相同版本的GCC(CC=gcc-4.2 CXX=g++4.2 ./configure --prefix=/usr/local),但结果没有变化。 --includedir& --libdir应设为$PREFIX/include&分别为$PREFIX/lib(特别是因为我没有指定--exec-prefix)因此我无法弄清楚为什么它无法找到GMP。

任何建议都非常赞赏。

更新

我在config.log中发现了以下内容,解释了未能找到GMP:

configure:6469: checking for __gmpz_getlimbn in -lgmp
configure:6494: gcc -o conftest -g -O2   conftest.c -lgmp   >&5
ld warning: in /usr/local/lib/libgmp.dylib, file is not of required architecture
Undefined symbols:
  "___gmpz_getlimbn", referenced from:
      _main in ccNP0jza.o
ld: symbol(s) not found 
collect2: ld returned 1 exit status
configure:6494: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "nettle"  
| #define PACKAGE_TARNAME "nettle"
| #define PACKAGE_VERSION "2.4"  
| #define PACKAGE_STRING "nettle 2.4"
| #define PACKAGE_BUGREPORT "nettle-bugs@lists.lysator.liu.se"
| #define PACKAGE_URL ""
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1 
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1 
| #define HAVE_UNISTD_H 1
| #define TIME_WITH_SYS_TIME 1
| #define SIZEOF_LONG 4
| #define HAVE_OPENSSL_BLOWFISH_H 1
| #define HAVE_OPENSSL_DES_H 1
| #define HAVE_OPENSSL_CAST_H 1
| #define HAVE_OPENSSL_AES_H 1
| #define HAVE_ALLOCA_H 1
| #define HAVE_ALLOCA 1 
| #define HAVE_STRERROR 1
| #define HAVE_GCC_ATTRIBUTE 1
| #define HAVE_FCNTL_LOCKING 1
| /* end confdefs.h.  */
|
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char __gmpz_getlimbn ();
| int
| main ()
| {
| return __gmpz_getlimbn ();
|   ;
|   return 0;
| }
configure:6503: result: no
configure:6514: WARNING: GNU MP not found, or not 3.1 or up, see http://gmplib.org/.
Support for public key algorithms will be unavailable.

运行file /usr/local/lib/libgmp.dylib会返回以下内容:

/usr/local/lib/libgmp.dylib: Mach-O 64-bit dynamically linked shared library x86_64

此服务器正在运行Intel Core 2 Duo处理器,因此64位Mach库对我来说是正确的。我不知道如何判断nettle是否正在为32位或64位架构构建,所以我尝试CC=gcc-4.2 CXX=g++4.2 ABI=64 ./configure --prefix=/usr/local没有任何变化(即使指定ABI=32 Nettle的{{1}总是说“ABI:标准”......它不通过ABI吗?)。

重新编译GMP作为静态库会有什么不同吗?(Nope,GMP默认构建静态和动态库。我在上面列出了所有已安装的文件。)

2 个答案:

答案 0 :(得分:4)

我在2.7版本中遇到了同样的问题。我最终让它工作的方式是强制它通过以下方式查看/ usr / local:

export CPPFLAGS="-I/usr/local/include"
export LDFLAGS="-L/usr/local/lib"
./configure

没有直接使用./configure选项的数量会让libnettle为我识别libgmp。

答案 1 :(得分:1)

事实证明,Nettle 2.4中包含的config.guess中存在一个错误,它在Mac OS X下没有检测到正确的32位/ 64位类型,因此它默认为32位且无法使用在GMP库中找到符号(编译为64位库)。正如Nettle开发人员所指出的here,您可以下载最新的config.guess和/或禁用汇编程序。

较新的config.guess对我不起作用,所以我强制它进入64位模式并禁用汇编程序。 Libnettle(和libhogweed;不包括GMP依赖性)的最终工作构建指令是:

curl -O http://www.lysator.liu.se/~nisse/archive/nettle-2.4.tar.gz
tar xzf nettle-2.4.tar.gz
pushd nettle-2.4
CFLAGS="-m64" ./configure --prefix=/usr/local --disable-assembler
make
sudo make install
popd