zoukankan      html  css  js  c++  java
  • 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 "33[31m start install ntl 33[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 << "
    ";
    	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

  • 相关阅读:
    vue-cli3 set vue.config.js
    oracle 基本查询语句及实例
    输出流啊输入流
    java线程
    sql基础
    抽象类和接口
    重载和重写的区别
    简单的java面向对象计算器
    运算符的优先级
    隐式类型转换规则
  • 原文地址:https://www.cnblogs.com/coming1890/p/14241465.html
Copyright © 2011-2022 走看看