It is STRONGLY advised to read through this entire doc page before getting started.
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
Supported Linux version
SOFA policy is to support only the latest Ubuntu LTS.
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 with this command:
GCC
To know which GCC versions are available for your distribution, run this command:
Then, install the latest one with the usual command (example with 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:
Then, install the latest one with the usual command (example with 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.
[optional] Ninja: build system
Ninja is an alternative to Make. It has a better handling of incremental builds.
[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.
Dependencies
Core (required)
SOFA requires some libraries:
-
tinyXML2
-
Qt (>= 5.12.0) with Charts and WebEngine
We recommend to install Qt in your user directory with the unified installer.
Make sure to enable Charts and WebEngine components.
- Qt Wayland:
X11 is known as an old display protocol. Recently, some Linux distributions switched to a new display protocol/server named Wayland.
If you are using Wayland, or to check whether you are using it:
- Run this command to check your protocol:
- If you are using Wayland, install the associated qtwayland running this command (here for Qt5):
and set the environment variable
export QT_QPA_PLATFORM=wayland
- Qt Wayland:
X11 is known as an old display protocol. Recently, some Linux distributions switched to a new display protocol/server named Wayland.
If you are using Wayland, or to check whether you are using it:
-
OpenGL
-
Boost (>= 1.65.1)
-
Python 3.10 + pip + numpy + scipy
-
Additional libraries: libPNG, libJPEG, libTIFF, Glew, Zlib
-
SOFA v20.06 and newer also need Eigen (>= 3.2.10)
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
- MeshSTEPLoader
- SofaAssimp
- SofaCUDA
The currently supported cuda version is 12.2 - SofaHeadlessRecorder
- SofaPardisoSolver
Building SOFA
Setup your source and build directories
To set up clean repositories, we recommend to arrange the SOFA directories as follows:
First, checkout the sources from Git repository:
Get the current stable version on the v24.06 branch:
OR get the development unstable version on the master branch:
Generate a Makefile with CMake
-
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".
-
Choose "Specify native compilers" and press "Next"
-
Set the C compiler to
/usr/bin/gcc
or/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 Troubleshooting section below). Do not worry about warnings.
-
(optional) Customize SOFA via CMake variables
-
choose the build type by setting CMAKE_BUILD_TYPE to "Release" or "RelWithDebInfo" (recommended) or "Debug"
- activate or deactivate plugins: see PLUGIN_XXX variables
- activate or deactivate functionalities: see SOFA_XXX variables
Do not forget to Configure again to check if your changes are valid.
- When you are ready, run Generate.
Compile
To compile, open a terminal in your build directory and run make
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 build 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!
Troubleshooting CMake errors
Qt detection error
To solve Qt detection errors, click on Add Entry and add
CMAKE_PREFIX_PATH
with path /home/YOUR_USERNAME/Qt/QT_VERSION/COMPILER
matching your
Qt installation.
Example: CMAKE_PREFIX_PATH=/home/bob/Qt/5.15/gcc_64
Then, Configure again.
A further dev warning may appear:
CMake Warning (dev) at YOUR_QT_PATH/lib/cmake/Qt5Core/Qt5CoreMacros.cmake:224 (configure_file):
configure_file called with unknown argument(s):
COPY_ONLY
Call Stack (most recent call first):
applications/projects/Modeler/exec/CMakeLists.txt:14 (qt5_add_resources)
This is just a typo with Qt5CoreMacros.cmake file. It uses COPY_ONLY instead of COPYONLY. Simply edit your Qt5CoreMacros.cmake, replace COPY_ONLY with COPYONLY and Configure again.
Compilation tutorial
See our page presenting video tutorial for compilation on Linux.