Environment: Using Vagrant and Virtual Box
Open the terminal of your host machine.
Create a folder:
Initiate vagrant project using ubuntu 16.04 xenial64:
Vagrant up to spawn the VM
Machine starts.
To login into the VM:
You will be logged in as ubuntu user.
To resynchronize the package index files from its sources:
Install these prerequisites before compiling:
Download the mpir library:
Unzip the downloaded zipped file:
Change directory to mpir-3.0.0
Run the following commands:
Once the above commands are successful, run:
MPIR produces libraries named libmpir, etc. under /usr/local/lib, and the header file mpir.h under /usr/local/include
Open the terminal of your host machine.
Create a folder:
mkdir mpir cd mpir
Initiate vagrant project using ubuntu 16.04 xenial64:
vagrant init ubuntu/xenial64
Vagrant up to spawn the VM
vagrant up --provider virtualbox
Machine starts.
To login into the VM:
vagrant ssh
You will be logged in as ubuntu user.
To resynchronize the package index files from its sources:
sudo apt-get update
Install these prerequisites before compiling:
sudo apt-get install yasm m4 build-essential unzip wget -y
Download the mpir library:
wget http://mpir.org/mpir-3.0.0-alpha2.zip
Unzip the downloaded zipped file:
unzip mpir-3.0.0-alpha2.zip
Change directory to mpir-3.0.0
cd mpir-3.0.0/
Run the following commands:
./configure
make
make check
Once the above commands are successful, run:
sudo make install
MPIR produces libraries named libmpir, etc. under /usr/local/lib, and the header file mpir.h under /usr/local/include
Create a soft link or set the variable to find mpir library which is not on a standard location:
sudo ln -s /usr/local/lib/libmpir.so.23 /usr/lib/
OR
export LD_LIBRARY_PATH=/usr/local/lib/
To test library is working, copy paste the code snippet
/*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" ; }
and run:
g++ test.cpp -lmpir -o test
./test
