在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            博客專欄

            EEPW首頁 > 博客 > 在Ubuntu上安裝NTL庫以及編譯測試

            在Ubuntu上安裝NTL庫以及編譯測試

            發(fā)布人:電子禪石 時間:2024-09-09 來源:工程師 發(fā)布文章

            這篇文章是21年第一次安裝的時候?qū)懙? 24年換電腦又需要重裝一遍, 還是按照這個做的, 

            連錯誤都一模一樣. 只要按順序做就能夠安裝成功.


            介紹:

            NTL是一個高性能的,可移植的c++庫,提供任意長度整數(shù)的數(shù)據(jù)結(jié)構(gòu)和算法;


            于整數(shù)和有限域上的向量、矩陣和多項(xiàng)式;并且適用于任意精度的浮點(diǎn)運(yùn)算。

            我們在Ubuntu中進(jìn)行安裝. (我使用的是Windows下的子系統(tǒng)wsl,但是應(yīng)該是一樣的)


            步驟:

            0. 下載前的準(zhǔn)備

            首先我們要確保必須有g(shù)++ 和 m4

            g++: sudo apt install g++

            m4: sudo apt install m4

            確認(rèn)安裝:g++ -v 和m4 --v

            ————————————————


            3. 對GMP進(jìn)行編譯

            首先我們把剛剛下載好的放到一起嗷。如下圖所示:

            然后進(jìn)入gmp這個文件夾
            一條一條依次輸入

            ./configure
            
            make
            
            make check
            
            sudo make install

            這一步應(yīng)該不存在問題,正確編譯后:
            輸入ls /usr/local/include/ 會看到gmp.h

            輸入ls /usr/local/lib/ 會看到一些這樣子的文件(我的可能多一些,因?yàn)槲沂莾蓚€實(shí)驗(yàn)做完截的圖)

            ls /usr/local/lib/
            libgmp.a   libgmp.so     libgmp.so.10.5.0   libmosquittopp.so.1  libmosquitto.so.1  python2.7
            libgmp.la  libgmp.so.10  libmosquittopp.so  libmosquitto.so      pkgconfig          python3.5
            4. 對NTL進(jìn)行編譯

            我們進(jìn)入ntl的文件夾中的src文件夾中,然后重復(fù)上面的指令:

            ./configure
            
            make
            
            make check
            
            sudo make install

            ATTENTION:這里在make過程中可能會出錯,下圖是我的報(bào)錯提示

            *** Checking for feature: COPY_TRAITS1 [yes]
            *** Checking for feature: COPY_TRAITS2 [yes]
            *** Checking for feature: CHRONO_TIME [yes]
            *** Checking for feature: MACOS_TIME [no]
            *** Checking for feature: POSIX_TIME [yes]
            *** Checking for feature: AES_NI [yes]
            *** Checking for feature: KMA [no]
            make[1]: Leaving directory '/mnt/hgfs/gitLab/ntl-11.5.1/src'
            make setup3
            make[1]: Entering directory '/mnt/hgfs/gitLab/ntl-11.5.1/src'
            g++ -I../include -I.  -g -O2 -std=c++11 -pthread -march=native   -o gen_gmp_aux gen_gmp_aux.cpp  -lgmp  -lm
            ./gen_gmp_aux > ../include/NTL/gmp_aux.h 
            NTL_GMP_LIP flag set
            GMP version check (6.3.0/6.1.0)
            *** version number mismatch: inconsistency between gmp.h and libgmp
            /bin/sh: line 1: 44940 Aborted                 (core dumped) ./gen_gmp_aux > ../include/NTL/gmp_aux.h
            makefile:360: recipe for target 'setup3' failed
            make[1]: *** [setup3] Error 134
            make[1]: Leaving directory '/mnt/hgfs/gitLab/ntl-11.5.1/src'
            makefile:324: recipe for target 'setup-phase' failed
            make: *** [setup-phase] Error 2

            我們看到說version number mismatch這一行是我們的出錯原因。
            這里我參考了 這個網(wǎng)站 中的某個回答,輸入sudo ldconfig, 把新安裝的gmp庫更新下即可解決此問題。

            Version number mismatch: inconsistency between gmp.h and libgmp - Stack Overflow

            https://stackoverflow.com/questions/50046463/version-number-mismatch-inconsistency-between-gmp-h-and-libgmp


            關(guān)于sudo ldconfig
            之后應(yīng)該順利進(jìn)行了,成功后如下圖所示:

            ls /usr/local/include/
            gmp.h  mosquitto.h  mosquitto_plugin.h  mosquittopp.h  nlohmann  NTL

            編譯測試:

            源文件test.cpp:

            #include <NTL/ZZ.h>
            
            using namespace std;
            using namespace NTL;
            
            int main()
            {
               ZZ a, b, c;
            
               cin >> a;
               cin >> b;
               c = (a+1) * (b+1);
               cout << c << "\n";
            }

            在命令行輸入:

            g++ test.cpp -o test.exe -lntl -pthread -lgmp

            就可以生成test可執(zhí)行文件,執(zhí)行即可。

            關(guān)于wsl下載和文件權(quán)限:

            關(guān)于wsl下載的一些事:

            如果把在Windows里下載解壓好的文件夾拖入U(xiǎn)buntu中,會發(fā)生權(quán)限問題,

            拖入的文件甚至連訪問都不可以,需要使用chmod -r 777 file_name指令去加權(quán)限

            (使用-r,因?yàn)樾枰f歸地改變,子文件也是都需要改的)。

            那比較簡單的替代方法就是在Windows中解壓后,在Ubuntu中使用cp指令復(fù)制一個過去

            (Windows磁盤掛載在mnt/中),這樣權(quán)限不會發(fā)生問題。


            參考資料:

            https://stackoverflow.com/questions/42607099/installing-ntl-with-gmp

            https://libntl.org/doc/tour.html(選項(xiàng)5,9)

            https://stackoverflow.com/questions/50046463/version-number-mismatch-inconsistency-between-gmp-h-and-libgmp

            https://zhuanlan.zhihu.com/p/66102855

            ————————————————


                                    

            原文鏈接:https://blog.csdn.net/weixin_45599342/article/details/121293041



                                    


            *博客內(nèi)容為網(wǎng)友個人發(fā)布,僅代表博主個人觀點(diǎn),如有侵權(quán)請聯(lián)系工作人員刪除。



            關(guān)鍵詞: ntl

            技術(shù)專區(qū)

            關(guān)閉