Hello,
I have compiled Nettle 3.3 with GMP 6.1.2 on a variety of systems (various Ubuntu/Debian distros, CentOS 7, Alpine) with success:
##### build GMP # pwd /tmp/gmp-6.1.2 # ./configure && make [...snip...] # find . -name "*.so" ./.libs/libgmp.so
###### build nettle # pwd /tmp/nettle-3.3 # CPPFLAGS="-I../gmp-6.1.2/" LDFLAGS="-L../gmp-6.1.2/.libs" ./configure && make
Again this works as expected on a variety of systems, except for CentOS 6 (using the centos:6 docker image). On CentOS 6 nettle configure fails with the following:
checking for GMP limb size... configure: error: in `/tmp/nettle-3.3': configure: error: cannot find value of GMP_NUMB_BITS
Full configure output: https://pastebin.com/9s3nfA8G
Oddly enough, if I install GMP (via 'make install') to a default search path, configure/make works as expected. Additionally, if I define LD_LIBRARY_PATH to the GMP lib build path (/tmp/gmp-6.1.2/.libs), the configure process works as expected, but we then encounter further errors when building (during the hogweed build process):
gcc -I.. -I.. -I../gmp-6.1.2/ -DHAVE_CONFIG_H -g -O2 -ggdb3 -Wno-pointer-sign -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -MT pkcs1-conv.o -MD -MP -MF pkcs1-conv.o.d -c pkcs1-conv.c && true In file included from ../rsa.h:38, from pkcs1-conv.c:47: ../bignum.h:54:18: error: gmp.h: No such file or directory
Which is very odd because we gmp.h definitely does exist (our gcc call has the following: -I../gmp-6.1.2/):
# file ../gmp-6.1.2/gmp.h ../gmp-6.1.2/gmp.h: ASCII C program text
FWIW, the gcc/m4 versions on CentOS 6 are fairly old:
[root@56de37e1bc78 nettle-3.3]# gcc --version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
[root@56de37e1bc78 nettle-3.3]# m4 --version m4 (GNU M4) 1.4.13
I tried upgrading GCC to 4.8 with no change; trying to update m4 was more than I wanted to chew off as it involved a libc change. Has anyone run into this behavior before? I wonder if this is potentially a bug with m4, but I'm not quite sure where to look at this point. Again we can work around our problem by installing GMP to a system dir (/usr/local/lib), but would like to avoid this if we can. One other thing I noted is that when running 'make install' in this environment, gmp installs to /usr/local/lib while nettle installs to /usr/local/lib64. Not sure if this is meaningful, or indicative of a compiler/configure flag that needs be adjusted for CentOS specifically (or any other
Robert Paprocki rpaprocki@fearnothingproductions.net writes:
Hello,
I have compiled Nettle 3.3 with GMP 6.1.2 on a variety of systems (various Ubuntu/Debian distros, CentOS 7, Alpine) with success:
###### build nettle # pwd /tmp/nettle-3.3 # CPPFLAGS="-I../gmp-6.1.2/" LDFLAGS="-L../gmp-6.1.2/.libs" ./configure && make
Using relative file names for -I and -L won't quite work, since they will point at the wrong place when make is run in subdirectories.
Again this works as expected on a variety of systems, except for CentOS 6 (using the centos:6 docker image). On CentOS 6 nettle configure fails with the following:
checking for GMP limb size... configure: error: in `/tmp/nettle-3.3': configure: error: cannot find value of GMP_NUMB_BITS
Full configure output: https://pastebin.com/9s3nfA8G
You should check config.log to investigate this kind of problems. My best guess is that the runtime linker can't find libgmp.so, you'd have to either set LD_LIBRARY_PATH, or add something like -Wl,-rpath,/tmp/gmp-6.1.2/... to LDFLAGS, or use --with-lib-path, in which case nettle's configure script will attempt to add the needed linker flags automatically.
Oddly enough, if I install GMP (via 'make install') to a default search path, configure/make works as expected.
The way I'd recommend, is to do a GMP make install with some suitable --prefix (/usr/local, /opt, /tmp/local, $HOME/local, whatever), and configure nettle with --with-include-path and --with-lib-path to point out the install location (using absolute file names).
gcc -I.. -I.. -I../gmp-6.1.2/ -DHAVE_CONFIG_H -g -O2 -ggdb3 -Wno-pointer-sign -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -MT pkcs1-conv.o -MD -MP -MF pkcs1-conv.o.d -c pkcs1-conv.c && true In file included from ../rsa.h:38, from pkcs1-conv.c:47: ../bignum.h:54:18: error: gmp.h: No such file or directory
Which is very odd because we gmp.h definitely does exist (our gcc call has the following: -I../gmp-6.1.2/):
# file ../gmp-6.1.2/gmp.h ../gmp-6.1.2/gmp.h: ASCII C program text
gcc and file are not running with the same working directory, that's why they get different results when attempting to open "../gmp-6.1.2/gmp.h". pkcs1-conv is built in the tools/ subdirectory.
Regards, /Niels
nettle-bugs@lists.lysator.liu.se