Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Building and Installing from Source

To build PIQP it is required to have CMake, Eigen 3.3.4+ and a compatible compiler like GCC, Clang, or Visual Studio with C++ extensions on Windows installed. CMake and a compatible compiler should already be installed on most systems.

Installing Eigen

on macOS via Homebrew

brew install eigen

on Ubuntu

sudo apt install libeigen3-dev

on Windows via Chocolatey

choco install eigen

building from source

# clone Eigen
git clone https://gitlab.com/libeigen/eigen.git eigen
cd eigen
git checkout 3.4.0

# build Eigen
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .

# install Eigen
cmake --install .

Building and Installing PIQP

  • Clone PIQP from Github recursively
    git clone https://github.com/PREDICT-EPFL/piqp.git --recurse-submodules
    
  • Build PIQP in a build folder
    cd piqp
    mkdir build
    cd build
    cmake .. -DCMAKE_CXX_FLAGS="-march=native" -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF
    cmake --build .
    

    Note that by setting -march=native, we allow the compiler to optimize for the full available instruction set on the machine compiling the code.

  • Install libraries and header files (requires CMake 3.15+)
    cmake --install .
    

    This will install the C++ and C headers and the static and shared library for the C interface.

Using PIQP in CMake Projects

PIQP has first class support for CMake project. The C++ library is header-only. For the C interface we provide a shared as well as a static library which can be linked against.

# Find PIQP package
find_package(piqp REQUIRED)

# PIQP requires at least C++14
set(CMAKE_CXX_STANDARD 14)

# Link the PIQP C++ header-only library
target_link_libraries(yourTarget PRIVATE piqp::piqp)

# Link the PIQP C shared library
target_link_libraries(yourTarget PRIVATE piqp::piqp_c_shared)
# or link the PIQP C static library
target_link_libraries(yourTarget PRIVATE piqp::piqp_c_static)