SOFA policy is to support only the latest Ubuntu LTS.
Installation with Pixi
You can download and build SOFA in only three steps without any environment installation.
Prerequisites
Installation steps
- Clone SOFA :
git clone https://github.com/sofa-framework/sofa:inbox_tray: - Trigger the build : run
pixi run -e supported-plugins buildin the sofa source folder :desktop_computer: - Launch SOFA : run
pixi run -e supported-plugins runSofa:rocket:
Alternative build methods
Manual installation (for developpers)
This installation method is advised for developers. It is STRONGLY advised to read through this entire doc page before getting started.
Build tools
Compiler
SOFA requires a C++17 compatible compiler.On Linux, we officially support GCC >= 7 and Clang >= 5.
First, install the standard compilation toolkit:
sudo apt install build-essential software-properties-common
GCC
To know which GCC versions are available for your distribution, run this command:apt-cache search '^gcc-[0-9.]+$'
Then, install the latest one with the usual command (example with gcc-11):
sudo apt install gcc-11
Clang
Clang is an alternative to GCC. It compiles approximately two times faster!We recommend to install Clang 5 or newer. To know which Clang versions are available for your distribution, run this command:
apt-cache search '^clang-[0-9.]+$'
Then, install the latest one with the usual command (example with clang-12):
sudo apt install clang-12
CMake: Makefile generator
CMake will be required to configure the SOFA project before compiling it. Note that SOFA requires at least CMake 3.22.sudo apt install cmake cmake-gui
[optional] Ninja: build system
Ninja is an alternative to Make. It has a better handling of incremental builds.sudo apt install ninja-build
[optional] CCache: caching system
We advise you to use ccache. It is by no means mandatory, but it will dramatically improve the compilation time if you make changes to SOFA.sudo apt install ccache
Dependencies
Core (required)
SOFA requires some libraries:- tinyXML2
sudo apt install libtinyxml2-dev - OpenGL
sudo apt install libopengl0 - Boost (>= 1.65.1)
sudo apt install libboost-all-dev - Python 3.12 + pip + numpy + scipy
Python 3.12 now favors the use of venv. We highly recommend it too. To bootstrap it, typesudo apt install python3.12-dev python3.12-venvpython3.12 -m venv sofa-venvin the folder you want to keep this venv. We recommend creating it either in your home directory or in the folder containing both your sources and the build directory. Once created, you can activate it by callingsource /path/to/sofa-venv/bin/activate. Now you can install all dependencies through the following commands:
Now, each time you want to build or use SOFA, you first need to callpython3.12 -m pip install --upgrade pip \ && python3.12 -m pip install numpy scipy pybind11==2.12.0source /path/to/sofa-venv/bin/activateto activate this virtual environment and get access to the dependencies. - Additional libraries: libPNG, libJPEG, libTIFF, Glew, Zlib
sudo apt install libpng-dev libjpeg-dev libtiff-dev libglew-dev zlib1g-dev - Eigen (>= 3.2.10)
sudo apt install libeigen3-dev
Graphical User Interface
The SOFAGLFW project is based on both GLFW and ImGui libraries. It requires the following dependencies to be installed:sudo apt install xorg-dev libgtk-3-dev
Plugins (optional)
SOFA plugins depend on libraries that are available in the official repositories.You probably don't need them all, but you might find it convenient to install them all and not worry about it later.
This list does not cover all available SOFA plugins, only the ones that are built by our continuous integration platform.
- CGALPlugin
sudo apt install libcgal-dev - SofaCUDA
The currently supported CUDA version is 12.2sudo apt install nvidia-cuda-toolkit
Build SOFA
Setup your source and build directories
To set up clean repositories, we recommend arranging the SOFA directories as follows:sofa/
├── build/
│ ├── master/
│ └── v25.12/
└── src/
└── < SOFA sources here >
First, checkout the sources from the Git repository:
Get the current stable version on the v25.12 branch:
git clone -b v25.12 https://github.com/sofa-framework/sofa.git sofa/src
OR get the development unstable version on the master branch:
git clone -b master https://github.com/sofa-framework/sofa.git sofa/src
Generate a Makefile with CMake
- Activate your venv:
and tell CMake to look there to find pybind11:source /path/to/sofa-venv/bin/activateexport CMAKE_PREFIX_PATH=/path/to/sofa-venv/lib/python3.12/site-packages - Create build directories respecting the arrangement above.
- Run CMake-GUI and set source folder and build folder.
- Run Configure. A popup will ask you to specify the generator for the project.
- If you installed Ninja, select
Ninja. - Otherwise, select
Unix Makefile.
- If you installed Ninja, select
- Choose
Specify native compilersand pressNext - Set the C compiler to
/usr/bin/gccor/usr/bin/clang
Set the C++ compiler to/usr/bin/g++or/usr/bin/clang++ - Run Configure.
- Fix eventual dependency errors by following CMake messages (see Troubleshoot section below). Do not worry about warnings.
- (optional) Customize SOFA via CMake variables
- choose the build type by setting
CMAKE_BUILD_TYPEtoReleaseorRelWithDebInfo(recommended) orDebug - activate or deactivate plugins: see
PLUGIN_XXXvariables - activate or deactivate functionalities: see
SOFA_XXXvariables
NOTE: here is an exhaustive list of plugins that can be activated for an in-tree compilation. - choose the build type by setting
- When you are ready, run Generate.
Compile
To compile, open a terminal in your build directory and runmake or ninja depending on the generator you chose during CMake configuration.If you chose
Unix Makefile as generator, you can enable parallel compilation by specifying the number of parallel builds you want by adding the -j n option with n being the number of desired parallel jobs.This is set automatically to the highest possible by
ninja, but this can be modified in the same way as for make.
Time for a coffee!To get assistance, see our page presenting video tutorial for compilation on Linux or use our GitHub Discussion forum.
Preconfigured Docker image
We provide preconfigured Docker images based on Ubuntu or Fedora.
These images contain all the tools and dependencies needed to build SOFA.
Feel free to use them and to propose your own versions on Docker Hub!
Ubuntu image: https://hub.docker.com/r/sofaframework/sofabuilder_ubuntu
Fedora image: https://hub.docker.com/r/sofaframework/sofabuilder_fedora
Nix package
Nix is a package manager which stores all packages into a common place called the Nix store, usually located at /nix/store. Each package is stored in a unique subdirectory in the store, and each package has its own tree structure.
A Nix package for SOFA is available and can be used as follows:
- Install Nix, you can run
sh <(curl -L https://nixos.org/nix/install) --daemon, restart your terminal or check the installation usingnix --version - From the SOFA sources, build using the command
nix build --extra-experimental-features nix-command --extra-experimental-features flakes(for master). Note that you can point towards any commit hash:nix build github:sofa-framework/sofa/COMMIT_HASH_HERE - Command
nix developprovides a shell with an environment containing all required dependencies to build the project in the usual CMake way - Finally, starts SOFA
nix run --impure .#nixgl --extra-experimental-features nix-command --extra-experimental-features flakes
Run SOFA
with the SOFA GUI
To run SOFA, locate and execute the application called runSofa. For more detailed information on how to use the application, you can refer to the page dedicated to runsofa. This documentation will provide you with further guidance on using SOFA effectively.
within a Python environment
To use SOFA within a Python3 environment, the section "using Python3" details how to set up your environment on various operating systems.