Skip to content

2: Compiling and installing SBGAT dependencies

bbercovici edited this page Feb 4, 2019 · 5 revisions

• Homebrew (Mac users only)

MacOSX users can install Homebrew to gain access to a powerful command-line package manager. Homebrew can be installed by running the following command in the terminal:

ruby -e "$(curl -fsSL https://github.com/raw/Homebrew/install/master/install)"

• CMake

After downloading and extracting the archive,

./bootstrap
make
make install

• Armadillo

After downloading and extracting the archive,

cmake .
make
sudo make install

Linux users may have to install additional libraries as explained here.

• RigidBodyKinematics

A C++ implementation of various useful rigid body kinematics routines

• OrbitConversions

A collection of orbit conversion routines

• YORPLib

A library of functions enabling one to compute the coefficients of the Fourier decomposition of the force, torque induced by solar insulation over a polyhedral surface.

• ShapeUQLib

Implementation of an analytical shape uncertainty and inertia statistics formulation tailored for small body analyses.

• SHARMLib

A library of functions enabling one to compute and evaluate the spherical harmonics expansion of the exterior gravity field caused by a constant density polyhedron

• OrbitConversions

A collection of orbit conversion routines

• Boost Libraries

Mac users

brew install boost

Linux (Ubuntu) users

sudo apt-get install libboost-all-dev

A lightweight C++ JSON parser. Nothing to do here as this one-header file library is already included in SbgatCore =)

• Qt

Getting Qt is pretty straightforward using the official online installer. Follow the installation procedure on Qt's website to download and install the latest version of the open source Qt distribution

• VTK

Download VTK Sources

The latest VTK release can be found on the VTK project website .

Create a VTK directory in which you will save the downloaded sources, like so. Create an empty VTK_release_build directory alongside VTK_source. Compilation will take place in the former.

VTK directory structure. The parent VTK directory can for instance be in ~/

Build VTK

Mac

The following cmake command will configure VTK on a Mac for usage with Qt installed at a non-standard location. The -DVTK_USE_QVTK:BOOL=ON , -DVTK_USE_GUISUPPORT:BOOL=ON , -DVTK_Group_Qt:BOOL=ON , -DModule_vtkIOExportOpenGL2:BOOL=ON and -DVTK_RENDERING_BACKEND:STRING=OpenGL2 as well as the Qt-related flags can be skipped if you do not intend to build SbgatGUI.

cd VTK_build
cmake  ../VTK_source/ -G "Unix Makefiles" -DCMAKE_PREFIX_PATH:PATH=/Users/bbercovici/Qt/5.10.0/clang_64/ -DVTK_USE_QVTK:BOOL=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DVTK_USE_GUISUPPORT:BOOL=ON -DQT_QMAKE_EXECUTABLE:PATH=~/Qt/5.10.0/clang_64/bin/qmake -DVTK_Group_Qt:BOOL=ON -DVTK_QT_VERSION:STRING=5 -DModule_vtkIOExportOpenGL2:BOOL=ON -DVTK_USE_CXX11_FEATURES:BOOL=ON -DVTK_RENDERING_BACKEND:STRING=OpenGL2

Note that the Qt version (Qt 5.10.0) explicitly appears at two locations in the cmake command. You will have to change this version number if a different version of Qt lives on your system.

It is possible to add a debug flag to the cmake command (-DVTK_DEBUG_LEAKS:BOOL=ON) so as to build VTK debug classes.

Nearly all the other build options are as suggested on the VTK tutorial page.

  1. If the cmake call exits with no error, VTK can then be compiled with
make -jN
make install

where 'N' should be the number of cores on your computer (setting N > 1 would put more threads on the compiling job, thus reducing its duration). Compiling VTK can take between 30 minutes and an hour.

Linux (Ubuntu)

Instructions are similar as above, minus the Qt paths directories which may be different then.

What if render window interactions are slow?

You may notice some lag while interacting with the shape displayed in the render window.

If your computer is equipped with a recent NVidia GPU, download the latest NVidia drivers from apt-get. As of July 2017:

sudo apt-get install nvidia-384

Rebooting the system should then yield noticeable improvements.

• Build GCC from source (Mac users only)

By default, Apple's Clang does not come with OpenMP support. Fortunately, there exists a way around, which consists in rebuilding the GCC compiler from source and using it instead of Clang.

First, check if you have already installed GCC from Homebrew by typing

brew ls --versions gcc

If this command returns a non-empty output, do

brew reinstall gcc --without-multilib

otherwise,

brew install gcc --without-multilib

Any of those two commands will download the GCC sources from Homebrew's repositories (gcc 7.2.0 as of 02/28/18) and compile them.

Be aware that this process may take up to an hour

The CMakeLists.txt file provided in SbgatCore directories will attempt to reset the compiler from Clang to the freshly compiled GCC.

• OpenBLAS, LAPACK, SuperLU (optional, non-Mac users only)

These three libraries can be compiled from their sources, available on their respective website (http://www.netlib.org/lapack/, www.openblas.net, http://crd-legacy.lbl.gov/~xiaoye/SuperLU/#superlu)

Their installation procedure is fairly similar and boils down to the following steps:

  1. Download and extract the source tarball. The extracted archive contains the library .cpp/.hpp files along with additional Install/Build instructions (often times located in a README.txt or INSTALL.txt file) and a CMakeLists.txt file.

  2. Add

set (CMAKE_POSITION_INDEPENDENT_CODE ON)

to the CMakeLists.txt of the library (which can be OpenBLAS, LAPAC, SuperLU...) before calling cmake in the next step. Otherwise errors may arise when compiling or when linking with Armadillo

  1. Unless specified otherwise in the Install/Build instructions, running the following commands sequentially should be sufficient to build and install the libraries (assuming an out-of-source build)
cmake ..
make
sudo make install