Quantitative Information Flow C++ library.

Star Fork Watch Issue Download
1 year after


Install via Homebrew

The easiest way to install libqif (especially on OSX) is via Homebrew:

brew tap chatziko/tap
brew install --HEAD libqif
brew test --HEAD libqif

On Linux: the method above is available via Linuxbrew. Make sure you have csh installed (needed only for the installation). Also, Linuxbrew installs everything under $HOME/.linuxbrew, so you need to either configure your system to use libraries from there, or symlink eveything under /usr/local:

sudo ln -s $HOME/.linuxbrew/include/qif* /usr/local/include/
sudo ln -s $HOME/.linuxbrew/lib64/libqif* /usr/local/lib/
sudo ldconfig

Compile a sample program

Create a simple test.cpp file:

#include <qif>
using namespace qif;

int main() {
    chan C("1 0 0; 0 1 0; 0 0 1");
    prob pi = probab::uniform<double>(3);
        << "Bayes vulnerability of \n"
        << C << " under " << pi << " is "
        << bayes::post_vulnerability(pi, C) << "\n";

Compile and run with:

g++ test.cpp -std=c++11 -lqif -larmadillo -o test

You can find more sample programs in the samples directory.

Depending on the functionality used, you might need to compile with any of the following:

-lglpk -lgsl -lgmp

Build libqif from source


  • CMake (tested with version 2.8.12)
  • Armadillo (tested with version 4.4)
  • GMP (tested with version 6.0.0)
  • GLPK (tested with version 4.54)
  • GSL (tested with version 1.16)
  • A C++11 compliant compiler (tested with g++ 4.9.1 and clang 7)

On Ubuntu, these can be installed with:

sudo apt-get install g++ cmake libarmadillo-dev libgmp-dev libglpk-dev libgsl0-dev

Get the code (note the --recursive to fetch the submodules).

git clone --recursive

To compile / install:

mkdir <path>/build && cd <path>/build
cmake ..
sudo make isntall

To run the tests

make tests

To build the samples:

make samples

Repository structure:

  • inc: headers
  • src: sources
  • tests: test cases
  • samples: sample programs
  • external: external libs (googletest)

Top Contributors

chatziko fmartinelli