Why can't Nettle 2.4's `configure` find GMP 5.0.2?

孤者浪人 提交于 2019-12-23 20:25:41

问题


I'm attempting to build GnuTLS on Mac OS X 10.5 (Leopard) Server (yeah, I know, it's a bit dated, but that's what this server is running at the moment) and am running into an issue building Nettle: I've built & installed GMP, but Nettle's configure cannot find it.

I built & installed GMP 5.0.2 as follows (the GCC version solution is from 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

A make check passes all tests and I end up with the following GMP files installed:

/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

However, when I attempt to build Nettle 2.4, as follows:

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

It builds & installs successfully, but it doesn't build libhogweed because GMP is missing. Upon further inspection, I've found the following warnings in the configure output:

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

Obviously, GMP 5.0.2 is newer than 3.1, plus both '__gmpz_getlimbn' & '__gmpz_powm_sec' are defined in /usr/local/include/gmp.h, so everything about my GMP install seems correct.

I've tried all sorts of configure options (esp. looking for some type of '--with-gmp' option) to no avail. I have also tried using the same version of GCC (CC=gcc-4.2 CXX=g++4.2 ./configure --prefix=/usr/local) as I did to compile GMP, with no change in result. --includedir & --libdir should be set to $PREFIX/include & $PREFIX/lib, respectively, (esp. since I'm not specifying an --exec-prefix) so I can't figure out why it wouldn't be able to find GMP.

Any suggestions would be greatly appreciated.

Update:

I found the following in config.log explaining the failure to find 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.

Running file /usr/local/lib/libgmp.dylib returns the following:

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

This server is running an Intel Core 2 Duo processor, so that 64-bit Mach library looks correct to me. I don't know how to tell whether nettle is trying to built for 32-bit or 64-bit architecture, so I tried CC=gcc-4.2 CXX=g++4.2 ABI=64 ./configure --prefix=/usr/local with no change (also, even when specifying ABI=32 Nettle's configure always says "ABI: standard"... does it not pass ABI through?).

Would re-compiling GMP as a static library make any difference? (Nope, GMP builds both static & dynamic libraries, by default. I listed both above when showing all the installed files.)


回答1:


I was having the same problem with version 2.7. The way I finally got it to work was to force it to look under /usr/local via:

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

No amount of playing with ./configure options directly would get libnettle to recognize libgmp for me.




回答2:


It turns out, there's a bug in config.guess included with Nettle 2.4 which does not detect the correct 32-bit/64-bit type under Mac OS X, so it was defaulting to 32-bit and couldn't find symbols in the GMP library (which was compiled as a 64-bit library). As the Nettle developer noted here, you can just download the latest config.guess and or disable assembler.

The newer config.guess didn't work for me, so I forced it into 64-bit mode and disabled assembler. The final working build instructions for Libnettle (and libhogweed; not including the GMP dependancy) are:

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


来源:https://stackoverflow.com/questions/7965990/why-cant-nettle-2-4s-configure-find-gmp-5-0-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!