Skip to content
Quantitative Information Flow C++ library.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status

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

To upgrade to the latest version:

brew reinstall --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

# or with clang
clang++ test.cpp -std=c++11 -lqif -larmadillo -o test

You can find more sample programs in the samples directory.

If the rat type is used you also need to compile with -lgmp -lgmpxx. If OR-Tools are used you also need to compile with -lortools.

Build libqif from source



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 install

To run the tests

make tests

To build the samples:

make samples

Use OR-Tools

If OR-Tools are installed in your system when libqif is compiled, they will be used by some libqif methods for linear optimization and network flow. cmake needs to be able to find OR-Tools for this to work: the only tested method is to install OR-Tools from source via cmake.

Repository structure:

  • inc: headers
  • src: sources
  • tests: test cases
  • samples: sample programs
  • external: external libs (googletest)
You can’t perform that action at this time.