A Swift wrapper around the GNU Multiple Precision Arithmetic Library (libgmp), largely compatible with the OpenSSL-based Swift big number library.
This package makes libgmp available for Swift as a system library target. Therefore, prior to compiling, you need to have a copy of libgmp installed for your operating system.
For apt-based Linux distributions (such as Debian or Ubuntu), you need to install the libgmp-dev
package first:
sudo apt install libgmp-dev
Install gmp
via Homebrew:
brew install gmp
This library uses the Swift Package Manager. To build and test use:
swift build -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib
swift test -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib
When you want to use pkg-config
instead of manually adding the linker paths, look into gmp.*.pc
, depending on your system. Make sure that the declared path fits your installation and make that file available to pkg-config
by using for example one of those commands:
export PKG_CONFIG_PATH=`pwd`:$PKG_CONFIG_PATH
ln -s /path/to/gmp.pc /usr/local/lib/pkgconfig/gmp.pc
At the moment, only a small number of BigInt
operations corresponding to the libgmp mpz
type are implemented.