71582

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

Question:

I'm attempting to build <a href="http://www.gnu.org/software/gnutls/" rel="nofollow">GnuTLS</a> 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 <a href="http://www.lysator.liu.se/~nisse/nettle/" rel="nofollow">Nettle</a>: I've built & installed <a href="http://gmplib.org/" rel="nofollow">GMP</a>, but Nettle's configure cannot find it.

I built & installed GMP 5.0.2 as follows (the GCC version solution is from <a href="http://gmplib.org/list-archives/gmp-bugs/2010-January/001838.html" rel="nofollow">here</a>):

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 <em>greatly</em> appreciated.

<strong>Update:</strong>

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?).

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

Answer1:

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.

Answer2:

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 <a href="http://comments.gmane.org/gmane.comp.encryption.nettle.bugs/206" rel="nofollow">here</a>, 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

Recommend

  • Add nodes in linked list
  • Close Modal Form when mouse click outside form area
  • CMake: Attempted to add link library to target which is not built in this directory
  • EmailConfirmation with FosUserBundle Does not work
  • Error installing R package for Linux
  • How to gernerate *.hsh file for “contacts+message backup” app on windows phone 8
  • Maven dependency doesn't find classes in default package
  • Naive parallelization in a .pbs file
  • NoClassDefFoundError: org/slf4j/LoggerFactory while creating a runnable *.jar with gradle
  • Curl issues with API call - could not resolve host
  • Can we solve the “printing neatly” problem using a greedy algorithm rather than dynamic programming?
  • Video-codec rater by image comparison algorithm?
  • Retrieving Data from Marvel's API in R (Error: is.response(x) is not TRUE)
  • H2O-R: Apply custom library function on each row of H2OFrame
  • base64 decode - nul in string
  • Dynamically add xtype items to the panel with slidenavigatoin
  • Set cookie only after file download complete.
  • Each user and their role in every database on the server
  • Unable to scan Code 128
  • what -j4 value is used to invoke make?
  • Prevent Emacs from modifying the OS X clipboard?
  • mysql Select one column twice from the same table with different dates in the where clause
  • Where can I get runkit DLL extensions for PHP 5.3+?
  • Typescript sourcemaps not loaded in chrome
  • Read stdin in chunks in Bash pipe
  • IIS 7.5 404 Error for .PDF files
  • vi mode to emacs mode while on R
  • How do I create an image and save it for later to draw as texture in XNA?
  • Javascript unload page condition
  • How to resolve dependencies from one gradle project to another gradle project in my Eclipse workspac
  • Specifying virtual keyboard type for EditText in XML
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • C: Incompatible pointer type initializing
  • Exchange data b/w iOS devices using Bluetooth 4.0
  • Modifying destination and filename of gulp-svg-sprite
  • Deserializing XML into class C#
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • python draw pie shapes with colour filled
  • How to Embed XSL into XML