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
    git clone https://github.com/PREDICT-EPFL/piqp.git
    
  • 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 . --config Release
    

    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 . --config Release
    

    This will install the C++ and C headers and shared libraries.

If you want to build static libraries instead, you can pass -DBUILD_SHARED_LIBS=OFF when configuring cmake.

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++ library with precompiled template instantiations
target_link_libraries(yourTarget PRIVATE piqp::piqp)

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

# Link the PIQP C library
target_link_libraries(yourTarget PRIVATE piqp::piqp_c)