Prerequisites for Windows
You need to have Visual Studio 2013 or higher installed. We recommend Visual Studio 2015 (tested on our Dashboard) or Visual Studio 2013 (to use the latest Qt5 64bit binaries). Both are available in Visual Studio downloads page.
CMake: Makefile generator
You need to have CMake 3.1 or higher installed. The easiest way to do this is to get the installer from the CMake download page.
Finally, SOFA requires some specific dependencies:
- Qt: you need to have Qt 4.8.3 or higher installed. We recommend to install Qt from the unified Windows installer.
WARNING: Choose the Qt version matching your compiler. If you choose Qt 5.4.x or lower, you will have to select an OpenGL version of the binary. There is not an OpenGL version for each compiler for each Qt version so this may force you to use an old Qt.
- Boost: you need to have Boost installed. You will find the last official Boost installer for every Visual Studio version here. SOFA is fully compatible with Boost 1.60.0 and older (not tested with newer versions). Beware of the correspondance between Visual Studio and MSVC versions (VS2013 = MSVC12, VS2012 = MSVC11, …).
- External libraries: some external libraries like Zlib or libXML2 are required.
- VS2013 users: download the SOFA dependencies for Windows using VS2013.
- VS2015 users: download the SOFA dependencies for Windows using VS2015.
You will unzip them in your sources folder (e.g. sofa/v16.12/src/) after cloning SOFA (see below).
To complete the dependencies integration, you can add Boost and Qt to your PATH.
Building on Windows
Setting up your source and build directories
To set up clean repositories, we propose to arrange the SOFA directories as follows:
First, download the sources from Git repository:
Get the current stable version on the v16.12 branch:
git clone -b v16.12 https://github.com/sofa-framework/sofa.git sofa/v16.12/src/
Or get the development unstable version on the master branch:
git clone -b master https://github.com/sofa-framework/sofa.git sofa/master/src/
Next, unzip in your sources folder (e.g. sofa/v16.12/src/) the SOFA dependencies for Windows you downloaded before.
Finally, you should have something like this:
Generate a Makefile with CMake
If you didn’t do it yet, create a build/ folder respecting directories arrangement.
Open CMake-GUI and set source folder with Browse Source and build folder with Browse Build.
To avoid Qt detection errors, click on Add Entry and add
CMAKE_PREFIX_PATH with path C:/Qt/QtX.X.X/X.X/msvcXXXX matching your Qt MSVC folder.
Next, run Configure. A popup window will ask you to specify the generator for the project. Using the drop down menu, select your preferred version of Visual Studio. If you have Visual Studio 2013 and a 64-bit system select "Visual Studio 12 2013 Win64". Keep "Use default native compilers" selected, and press "Finish".
You need to run Configure twice, since SOFA requires two passes to manage the module dependencies. You can then customize your version of SOFA, activate or deactivate plugins and functionalities.
A further dev warning may appear:
CMake Warning (dev) at YOUR_QT_MSVC_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.
WARNING: With v15.03, v15.09 and v16.08, no error shows up concerning Boost (miniBoost is integrated with sources). But since Boost is needed by several plugins, we decided to remove miniBoost from our future releases. So you better learn now how to manually tell to CMake where are Boost libraries.
In CMake-GUI, check the Advanced box (right from Search text-box) and search for "Boost". Manually set
Boost_INCLUDE_DIR with your Boost root directory if it is empty. Manually set
Boost_THREAD_LIBRARY_DEBUG with absolute path of boost_thread-vcXXX-mt-gd-1_XX.lib and
Boost_THREAD_LIBRARY_RELEASE with absolute path of boost_thread-vcXXX-mt-1_XX.lib.
Then run Configure twice (you should see no more red entries). Other Boost libraries should be auto-detected.
Expected result for VS2013 64-bit build with Boost 1.59.0 installed in C:/boost/ :
When you are ready, press Generate. This will create your Visual Studio solution.
If you are using Visual Studio, building SOFA is just like any other project building. Simply open the generated Sofa.sln and build the solution.
Time for a coffee !
Last modified: 27 January 2017