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 CentOS.
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!
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:
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-7):
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-5.0):
CMake: Makefile generator
SOFA requires at least CMake 3.12.
We recommend to install CMake using the latest official installer.
[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.
SOFA requires some libraries:
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.
Boost (>= 1.65.1)
Additional libraries: libPNG, libJPEG, libTIFF, Glew, Zlib
SOFA v20.06 and newer also need Eigen (>= 3.2.10)
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.
Setup your source and build directories
To set up clean repositories, we recommend to arrange the SOFA directories as follows:
sofa/ ├── build/ │ ├── master/ │ └── v20.12/ └── src/ └── < SOFA sources here >
First, checkout the sources from Git repository:
Get the current stable version on the v20.12 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 “CodeBlocks – Ninja”.
- Otherwise, select “CodeBlocks – Unix Makefile”.
Choose “Specify native compilers” and press “Next”
Set the C compiler to
Set the C++ compiler to
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.
To compile, open a terminal in your build directory and run
ninja depending on the generator you chose during CMake configuration.
Do not forget the
-j option to use all your CPU cores.
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 architecture.
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.
See our page presenting video tutorial for compilation on Linux.
Last modified: 26 March 2021