Eigen
Pieter PThis page explains how to install the Eigen linear algebra library on Ubuntu.
Install dependencies and tools
First, install GCC, CMake, GNU Make and Git if you haven't already.
sudo apt updatesudo apt install gcc g++ cmake make git
Download and install
#!/usr/bin/env bash# Script to download and install Eigen3set -exversion="3.3.7" # Release tag on GitLabprefix="$HOME/.local"cd /tmp# Downloadgit clone --single-branch --depth=1 --branch "$version" \https://gitlab.com/libeigen/eigen.gitmkdir eigen/build && cd $_# Configurecmake .. \-DCMAKE_BUILD_TYPE=Release \-DCMAKE_INSTALL_PREFIX="$prefix"# Installmake install
Usage
To use Eigen in your project, you can use the following CMake snippet:
find_package(Eigen3 REQUIRED)add_executable(eigen-demo main.cpp)target_link_libraries(eigen-demo PRIVATE Eigen3::Eigen)
CMake has to find Eigen, so you need to make sure that $HOME/.local
is in its search paths. See Installing Locally.
Tested on
- Ubuntu 20.04 - Eigen 3.3.7