【问题标题】:Why can't Nettle 2.4's `configure` find GMP 5.0.2?为什么 Nettle 2.4 的 `configure` 找不到 GMP 5.0.2?
【发布时间】:2011-12-19 10:35:57
【问题描述】:

我正在尝试在 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

它构建和安装成功,但它没有构建libhogweed,因为缺少 GMP。经过进一步检查,我在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 的 configure 总是说“ABI : 标准"...它不通过 ABI 吗?)。

将 GMP 重新编译为静态库会有什么不同吗?(不,默认情况下,GMP 同时构建静态库和动态库。我在显示所有已安装文件时都在上面列出了。)

【问题讨论】:

    标签: macos gnu configure ssl gmp


    【解决方案1】:

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

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

    直接使用 ./configure 选项再多也不会让 libnettle 为我识别 libgmp。

    【讨论】:

      【解决方案2】:

      事实证明,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
      

      【讨论】:

      猜你喜欢
      • 2013-07-23
      • 1970-01-01
      • 1970-01-01
      • 2021-07-19
      • 2014-06-04
      • 1970-01-01
      • 1970-01-01
      • 2017-06-20
      • 1970-01-01
      相关资源
      最近更新 更多