BigInt is an awesome library that allow us to write C/C++ programs that use arbitrary precision arithmetic. Here we'll go through on how to setup the library as a shared object under GNU/Linux (Kubuntu).

# download the library
wget https://mattmccutchen.net/bigint/bigint-2010.04.30.tar.bz2 --no-check-certificate
# extract it
tar -xvf bigint-2010.04.30.tar.bz2
# rename it to bigint
mv bigint-2010.04.30 bigint
# copy it to the include dir
sudo mkdir -p /usr/local/include/bigint/
sudo cp bigint/* /usr/local/include/bigint/
# creating shared library
# create object files
g++ -fpic -c BigInteger.cc BigIntegerAlgorithms.cc BigIntegerUtils.cc BigUnsigned.cc BigUnsignedInABase.cc
# create shared library called libbigint.so which can be invoked using -lbigint
g++ -shared -o libbigint.so BigInteger.o BigIntegerAlgorithms.o BigIntegerUtils.o BigUnsigned.o BigUnsignedInABase.o
# copy it into the local lib dir
sudo cp libbigint.so /usr/local/lib/
# configure ldconfig (dynamic linker runtime bindings) to rebuild the shared library cache
# note that ldconfig should contain the path where you copied the libbigint.so file
# /usr/local/lib is already added. You can add additional paths in /etc/ld.so.conf.d/
sudo /sbin/ldconfig -v /usr/local/lib

-fpic or -fPIC means position independent code.

Now that the library & the environment is ready, let's write a small program and verify it.

// big.cpp
#include <iostream>
#include <bigint/BigIntegerLibrary.hh>
 
using namespace std;
 
int main()
{
    BigInteger a = 31415926535;
    cout << a * a * a * a * a * a * a * a << endl;
    return 0;
}

Compile & run

g++ big.cpp -o big -lbigint
./big
948853101390095872711467085400133633064593764027907283066796117781702198979687890625