Ubuntu18.04安装ntl库

首先去官网下载安装包,下列shell脚本与安装包放到同一目录,赋予此脚本执行权限。另外,我这里默认你的电脑上面已经安装gcc,g++,make。

#apt install -y gcc
#apt install -y g++
#apt install -y make
apt install -y autoconf

apt install -y m4
apt install -y libgmp-dev
apt install -y libgf2x-dev

tar zxvf ntl-11.4.3.tar.gz

mv ntl-11.4.3 ntl
 
echo -e "\033[31m start install ntl \033[0m"
cd ntl/src
./configure NTL_GF2X_LIB=on
make && make check && make install
cd - >> /dev/null
 
rm -r ntl

测试一下:新建一个rand.cpp(顾名思义,是输出随机数)

#include <NTL/ZZ.h>
#include <time.h>
NTL_CLIENT
int main()
{
	ZZ a,b,c;
	SetSeed(to_ZZ(time(NULL)));
	RandomLen(a, 32);
	RandomLen(b, 32);
	c = a + b;
	cout << "a=" << a << ", b=" << b << ", c=" << c << "\n";
	return 0;
}

按照官网的介绍,使用如下命令编译:

g++ -g -O2 -std=c++11 -pthread -march=native rand.cpp -o rand -lntl -lgmp -lm

其中rand.cpp是c++文件,rand是编译后的可执行文件。程序运行效果如下:

$ ./rand
a=2298665095, b=3622090486, c=5920755581

参考链接:
NTL库快速上手中文指南
A Tour of NTL

原文链接: https://www.cnblogs.com/coming1890/p/14241465.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    Ubuntu18.04安装ntl库

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/206980

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 下午10:45
下一篇 2023年2月12日 下午10:46

相关推荐