20

I'm trying to compile GnuTLS library several times on Centos 6.2 but with no luck. These are the steps:

I downloaded Nettle 2.4

[root@localhost opt]# wget http://www.lysator.liu.se/~nisse/archive/nettle-2.4.tar.gz
[root@localhost nettle-2.4]# tar zxvf nettle-2.4.tar.gz
[root@localhost nettle-2.4]# cd nettle-2.4
[root@localhost nettle-2.4]# ./configure --enable-shared --prefix=/usr



  Version:           nettle 2.4
  Host type:         x86_64-unknown-linux-gnu
  ABI:               64
  Assembly files:    x86_64
  Install prefix:    /usr
  Library directory: ${exec_prefix}/lib64
  Compiler:          gcc
  Shared libraries:  yes
  Public key crypto: no

I run the command make and make install

I downloaded the latest GnuTLS

 ./configure --with-libnettle-prefix=/usr

hecking for shared library run path origin... done
checking whether to use nettle... yes
checking for libnettle... no
configure: error:
  ***
  *** Libnettle 2.4 was not found.

What am I missing?

Best wishes

Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
  • 2
    Like the message says, you appear to be missing libnettle. Whatever that is. :) –  Mar 01 '12 at 00:33
  • 4
    Probably the problem is that libnettle has installed in `/usr/lib64` (as indicated by the output when you `configure`-ed nettle) & `configure` script in `GnuTLS` is looking for it in `/usr/lib`. You could try passing additional option `--with-libdir=lib64` (untested) to `configure` script of `GnuTLS` – another.anon.coward Mar 01 '12 at 03:58
  • You could check configure.log for some more specific output from that test. – XTL Mar 01 '12 at 08:58
  • If you are looking for a recipe based answer to *"How to build GnuTLS"*, then see [GitHub | Build-Scripts](https://github.com/noloader/Build-Scripts). It includes a recipe to build GnuTLS and its dependencies from the latest release tarballs. I use the scripts for downlevel clients like CentOS 5 and ransomware clients like Solaris. The scripts allow me to use an updated cURL, Git, GnuTLS, Wget, OpenSSL, SSH, and friends on the machines. – jww Jul 22 '18 at 04:04

7 Answers7

24

The issue is that nettle won't build libhogweed unless, as you've observed, the dev headers for libgmp are present. Unfortunately, the docs and .configure --help and output from configure don't say anything about this.

Meanwhile, the gnuTLS docs don't explain this either (and as you notice, its configure output here is not very helpful). Although libgmp is listed as a pre-req, for some reason libhogweed is not (perhaps because it is assumed to be part of nettle). The reason for your configure error "cannot find -lgmp" is that libgmp isn't present, but libhogweed.so won't be there either, since it is a hidden optional part of nettle. If you then install libgmp-dev and just run configure for gnutls, you'll get the same "checking for libnettle... no". What this should say is "checking for libhogweed... no", but whoever is in charge of the conf script is too lazy to break that up (I guess a patch could be submitted).

In other words, you need to install libgmp-dev and then rebuild nettle before you build gnutls.

CodeClown42
  • 11,194
  • 1
  • 32
  • 67
  • Your solution (installing `pkg-config`) would be prerequisite as well, although that is more generally true for building software on GNU/Linux that links against commonplace external libs. – CodeClown42 Sep 06 '16 at 10:15
  • For me, just attempting the make of `gnutls` was sufficient for creating the headers that `nettle` needed (that is, _no_ libgmp-dev was needed). Going back and rebuilding `nettle` built `libhogweed` (but then threw the error `sexp2rsa-test.c:40: undefined reference to 'test_rsa_key'`, which I decided to ignore, and just do `make install`) That _seemed_ to do the trick, and 'gnutls' re-built with libhogweed. – Randall Oct 07 '16 at 21:49
4

I installed nettle-dev & nettle-bin and it works :)

MarkWong
  • 51
  • 3
3

Gnu TLS configure script does not say out loud that pkg-config is needed and other package may not even be tried if pkg-config is not installed. Installing pkg-config fixed the issue for me.

Mohammad Azim
  • 2,604
  • 20
  • 21
1

Actually the problem was in configure script, incorrectly invoking the pkg-config Looks like its due to the version differences in autogen files. Anyway I fixed it in configure script.

They invoke pkg-config with => operator but libnettle names itelf incorrectly. For example, they invoke $PKG_CONFIG --libs "nettle >= 3.4.1" 2>/dev/null

The fix : so I just removed "=> 3.4.1" substring and voila:

    if test -n "$NETTLE_CFLAGS"; then
    pkg_cv_NETTLE_CFLAGS="$NETTLE_CFLAGS"
 elif test -n "$PKG_CONFIG"; then
    if test -n "$PKG_CONFIG" && \
    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nettle\""; } >&5
  ($PKG_CONFIG --exists --print-errors "nettle") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then
  pkg_cv_NETTLE_CFLAGS=`$PKG_CONFIG --cflags "nettle" 2>/dev/null`
              test "x$?" != "x0" && pkg_failed=yes

its for CFLAGS and down below for LIBS flag:

if test -n "$NETTLE_LIBS"; then
    pkg_cv_NETTLE_LIBS="$NETTLE_LIBS"
 elif test -n "$PKG_CONFIG"; then
    if test -n "$PKG_CONFIG" && \
    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nettle\""; } >&5
  ($PKG_CONFIG --exists --print-errors "nettle") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then
  pkg_cv_NETTLE_LIBS=`$PKG_CONFIG --libs "nettle" 2>/dev/null`
              test "x$?" != "x0" && pkg_failed=yes
else
  pkg_failed=yes
fi
 else
    pkg_failed=untried
fi
barney
  • 2,172
  • 1
  • 16
  • 25
1

GnuTLS depends on nettle which is missing on your environment.

  • You can download the nettle package and install
cd nettle-xxx
./configure 
make 
sudo make install
  • Or if it is ubuntu system you can install from apt
sudo apt install nettle-dev nettle-bin
rashok
  • 12,790
  • 16
  • 88
  • 100
1
configure:8798: checking for libnettle
configure:8820: gcc -std=gnu99 -o conftest -g -O2   conftest.c  /usr/lib/libnettle.so /usr/lib/libhogweed.so -lgmp >&5
/usr/bin/ld: cannot find -lgmp
collect2: ld returned 1 exit status
configure:8820: $? = 1
configure: failed program was:
configure:8830: result: no
configure:8856: error: 
  ***
  *** Libnettle 2.4 was not found.

I install gmp-devel. The problem is fixed.

Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
  • 2
    I installed `pkg-config` and that solved the problem. Possibly, installing `autogen` also helped - at least, it removed a warning. – ssc May 17 '14 at 17:32
  • That doesn't explain the root of the problem. It's just a platform specific i.e. Linux way of solution. – Terry Aug 29 '19 at 16:13
0

Had this problem on Debian for a while, try installing pkgconf package.