SOFA policy is to support only the latest MacOS version.
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:
⚠️ A known issue under macOS has been hotfixed in the pixi build using a patch. You don't need to do anything while using pixi, it is applied for you. FYI, the issue appeared through the use of Python from runSofa with SofaPython3 and caused a segmentation fault due to symbol duplication (the Python package from Conda Forge statically linked with libpython, conflicting with runSofa’s own linking). The patch (proposed in PR #394) is currently used in our Conda packages.
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 MacOS, we officially support MacOS >= 10.13.2 (High Sierra) and AppleClang >= 9.1.0. Check your MacOS version with
system_profiler SPSoftwareDataTypeCheck your AppleClang version with
clang --version
If your MacOS version is too low, update your Mac from the App Store.
If your AppleClang version is too low:
- Download and install the highest possible Xcode compatible with your MacOS.
Compatibility list (taken from Wikipedia):
To download any version, go to https://developer.apple.com/download/more/ and search for "Xcode".MacOS >= 11.3 : Xcode 13.2.1 (with AppleClang 13.0.0) MacOS >= 11.0 : Xcode 12.5.1 (with AppleClang 12.0.5) MacOS >= 10.15.4 : Xcode 12.4 (with AppleClang 12.0.0) MacOS >= 10.15.2 : Xcode 11.7 (with AppleClang 11.0.3) MacOS >= 10.14.4 : Xcode 11.3.1 (with AppleClang 11.0.0) MacOS >= 10.14.3 : Xcode 10.3 (with AppleClang 10.0.1) MacOS >= 10.13.6 : Xcode 10.1 (with AppleClang 10.0.0) MacOS >= 10.13.2 : Xcode 9.4.1 (with AppleClang 9.1.0) - Open Xcode to automatically finalize installation
- In Xcode, navigate to "Xcode > Preferences > Locations" and set Command Line Tools to your Xcode version
- Verify Command Line Tools path:
xcode-select -p
If it is not pointing to your Xcode, change it:xcode-select --switch /Applications/Xcode.app - Reboot
CMake: Makefile generator
SOFA requires at least CMake 3.22.brew install --cask cmake
[optional] Ninja: build system
Ninja is an alternative to Make. It has a better handling of incremental builds.brew install ninja
[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.brew install ccache
Dependencies
Core (required)
SOFA requires some libraries:- tinyXML2
brew install tinyxml2 - Boost (>= 1.65.1)
brew install boost - Python 3.12 + pip + numpy + scipy
Python 3.12 now favors the use of venv. We highly recommend it too. To bootstrap it, typebrew install python@3.12 brew link --force python@3.12python3.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
brew install libpng libjpeg libtiff glew - Eigen (>= 3.2.10)
brew install eigen
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
brew install cgal - SofaCUDA
brew install homebrew/cask-drivers/nvidia-cuda
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.app 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 (recommended), select
CodeBlocks - Ninja. - Otherwise, select
CodeBlocks - Unix Makefile.
- If you installed Ninja (recommended), select
- Keep
Use default native compilersand pressDone. - Fix eventual dependency errors by following CMake messages (see Troubleshoot section below). Do not worry about warnings.
- Customize SOFA via CMake variables
- choose the build type by setting
CMAKE_BUILD_TYPEtoReleaseorRelWithDebInfo(recommended) orDebug - if your Mac has a M1 processor: set
CMAKE_OSX_ARCHITECTUREStoarm64 - 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.Do not forget the
-j option to use all your CPU cores.
Time for a coffee!
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.