Windows Subsystem for Linux, aka. bash on windowsにmpir libraryをインストールする。
まず、ターミナルを立ち上げて、システムを最新の状態にする。
sudo apt update && sudo apt dist-upgrade -y
ライブラリをコンパイルするのに必要なパッケージをインストールする。
sudo apt-get install yasm m4 build-essential unzip wget -y
mpir libraryをmpir.orgサイトからダウンロードする。
wget http://mpir.org/mpir-3.0.0-alpha2.zip
ダウンロードしたzipファイルをunzipする。
unzip mpir-3.0.0-alpha2.zip
ディレクトリをファイルをunzipしたフォルダーに変える。
cd mpir-3.0.0/
以下のコマンドを順番に実行する。
1 2 3 | ./configure make make check |
上記のコマンドが滞りなく実行されたらインストールを実行する。
sudo make install
libmpir等のライブラリは/usr/local/lib
に、mpir.hは/usr/local/include
に作られる。
インストール先のディレクトリにpathを通す。
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
テストプログラムを走らせてインストールが正常に完了したかをテストする。
test.cppというファイルを作って下記のコードをコピペする。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /*Program to check the Working of mpir library */ #include<mpir.h> #include<stdio.h> #include<iostream> using namespace std; int main() { mpf_t a; //mpir float variable mpf_init(a); //initialise a mpir_ui two = 2; //mpir unsigned integer variable FILE* stream; //file type pointer to output on standard output (console) mpf_init_set_ui (a, 2); //set value of a to 2 mpf_out_str (stream, 10, 2, a); //output value of a cout << "\nMPIR working" << "\n" ; } |
コードをコンパイルして実行できたら無事完了。
1 2 | g++ test.cpp -lmpir -o test ./test |
0.2e1
MPIR working
Press <RETURN> to close this window...
MPIR working
Press <RETURN> to close this window...
mpirライブラリは無事インストールされた。
参考サイトMPIR library installation on Ubuntu 16.04スポンサーリンク