怎样安装nettle

2016年8月9日 | 分类: 【技术】

【介绍】

官网:http://www.lysator.liu.se/~nisse/nettle/

【rpm安装最新版本】

下载:https://fedora.pkgs.org/29/fedora-x86_64/nettle-3.4-5.fc29.x86_64.rpm.html
下载:https://fedora.pkgs.org/29/fedora-x86_64/nettle-devel-3.4-5.fc29.x86_64.rpm.html

yum install http://download-ib01.fedoraproject.org/pub/fedora/linux/releases/29/Everything/x86_64/os/Packages/n/nettle-3.4-5.fc29.x86_64.rpm
yum install http://download-ib01.fedoraproject.org/pub/fedora/linux/releases/29/Everything/x86_64/os/Packages/n/nettle-devel-3.4-5.fc29.x86_64.rpm

【源码编译安装最新版本】

参考:http://linuxfromscratch.org/blfs/view/svn/postlfs/nettle.html

要求:OpenSSL-1.0.2h

下载:http://ftp.gnu.org/gnu/nettle/
下载:https://github.com/gnutls/nettle

最新版本:nettle 3.5.1 (适用于 gnutls 3.6.9 )

wget http://ftp.gnu.org/gnu/nettle/nettle-3.5.1.tar.gz && tar -xzvf nettle-3.5.1.tar.gz && cd nettle-3.5.1
./configure --prefix=/usr --disable-static && make && make install
install -v -m755 -d /usr/share/doc/nettle-3.5.1 && install -v -m644 nettle.html /usr/share/doc/nettle-3.5.1

实证版本:nettle 3.4.1 (适用于 gnutls 3.6.8 )

wget http://ftp.gnu.org/gnu/nettle/nettle-3.4.1.tar.gz && tar -xzvf nettle-3.4.1.tar.gz && cd nettle-3.4.1
export CFLAGS="-std=c99"
./configure --prefix=/usr --disable-static && make && make install
chmod -v 755 /usr/lib64/lib{hogweed,nettle}.so && install -v -m755 -d /usr/share/doc/nettle-3.4 && install -v -m644 nettle.html /usr/share/doc/nettle-3.4
export CFLAGS=""

输出:

...
/usr/bin/install -c -m 644 "./$f" /usr/include/nettle ; \
...
/usr/bin/mkdir -p /usr/lib64/pkgconfig
...
/usr/bin/install -c -m 644 "$f" /usr/lib64/pkgconfig ; \
...
/usr/bin/install -c -m 644 libnettle.so /usr/lib64/libnettle.so.6.4
...
/usr/bin/install -c -m 644 libhogweed.so /usr/lib64/libhogweed.so.4.4
...

安装完成。

相关文件路径:

/usr/include/nettle/nettle-meta.h
/usr/lib64/libnettle.so.6.2
/usr/lib64/libhogweed.so.4.2
/usr/lib64/pkgconfig/nettle.pc
/usr/lib64/pkgconfig/hogweed.pc

查看版本:

nettle-hash --version

输出:

nettle-hash (nettle 3.4.1)

更新系统动态连接库配置:

echo /usr/lib64 >> /etc/ld.so.conf && ldconfig

环境参数:

NETTLE_CFLAGS="-I/usr/include/nettle" NETTLE_LIBS="-L/usr/lib64 -lnettle" HOGWEED_CFLAGS="-I/usr/include/nettle" HOGWEED_LIBS="-L/usr/lib64 -lhogweed" 

【排错】

当 make 时报错:error: ‘for’ loop initial declarations are only allowed in C99 mode

参考:http://amon.org/gcc

export CFLAGS="-std=c99"

然后重新:

./configure --prefix=/usr --disable-static && make && make install

务必清除环境变量修改:

export CFLAGS=""