Installing MBDyn - zanoni-mbdyn/blendyn GitHub Wiki
Chances are, if you are here, that you already are an MBDyn user, and thus you don't need to install it. This section was written for the convenience of the inexperienced users. It is be also useful to highlight which is the recommended MBDyn configuration that allows to get the most out of Blendyn.
- MacOS (outdated, last tested on 10.15.7) installation guide
- Windows installation guide
- GNU/Linux [Ubuntu] installation guide (same as before: what you do in the WSL is what you would do in a Debian/Ubuntu terminal)
- GNU/Linux [Arch] installation guide: follow along...
Since June 2023, the AUR package
mbdyn-git is available. The package
will automatically build MBDyn following the process described below, and is
optimized for the use of Blendyn by default. The latest version of the develop
branch is downloaded.
You install it in the usual way you install AUR packages. For example:
$ git clone https://aur.archlinux.org/mbdyn-git.git
$ cd mbdyn-git/
$ makepkg -si
or with your distribution AUR manager (yay
, pamac
, etc...)
MBDyn is a software that is designed and developed mostly by people using GNU/Linux and it is distributed only in source code form. It is compiled from the source code using GNU's autotools. It can be built also on Windows using MinGW or, under Windows 10 and above, the Windows Subsystem for Linux. Look here for a complete guide to install both MBDyn and Blendyn under Windows 10 using the WSL. Note that the same guide contains also, in practical terms, MBDyn installation instructions for Debian/Ubuntu.
In this guide I'll assume that you are working in a GNU/Linux environment. I'll use my currently preferred distribution, Arch as a reference for the commands. Differences with other distributions, as it pertains to this guide, are only related to the package manager: for example, Arch relies on pacman, Debian/Ubuntu and OpenSUSE on Apt, Fedora on dnf, etc... So the name of the packages and the commands might change a bit for you if you do not use Arch, but the general procedure remains the same.
The basic packages needed to be able to compile MBDyn are GNU's autotools, GNU's autoconf, GNU's libtool, and a fortran compiler, for example gfortran.
In Arch, you can install all of them with
$ sudo pacman -S base-devel gcc-fortran
The MBDyn package is highly modular: it allows the user (you) to customize a lot the installation by requiring only a minimal set of external libraries in the baseline configuration, and optionally enabling more functionalities if the required additional libraries are found. Here, I will list the ones that are useful for Blendyn, and a few more not directly related to Blendyn that I recommend you to install before building MBDyn.
To to get the most out of Blendyn, it is recommended to at least enable the binary (NetCDF) output feature of MBDyn. This is accomplished by installing the NetCDF/C++ library.
The related packages in Arch are the netcdf
and netcdf-cxx
packages:
$ sudo pacman -S netcdf netcdf-cxx
If you use a different distribution, keep in mind that often
library packages are available in two versions: one without
headers, the other
with the headers, usually having a name containing a suffix dev
or devel
. This is not the case in Arch: all the Arch packages
contain header files (and are therefore directly available to be
linked by other software during builds).
If you are interested in performing eigenanalyses in MBDyn and visualize the eigensolutions (i.e., the vibration modes) in Blendyn, you need to install one of the libraries that MBDyn relies on for this particular problem.
The recommended one is LAPACK. You can install it in Arch with
$ sudo pacman -S lapack
Optionally, you can also install ARPACK, which gives you an alternative to LAPACK:
$ sudo pacman -S arpack
Remember than in other distributions it might be needed to install the development version of the library.
MBDyn functionalities are often extended through run-time modules , i.e. libraries that are loaded during the execution, only if they are requested by the specific problem MBDyn is asked to solve.
To enable modules , the GNU Libtool library has to be made available.
In Arch, the related package is called libtool
, and can be installed with
sudo pacman -S libtool
other frequently used names for the same package contain the acronym ltdl
:
for example, the Debian/Ubuntu equivalent package is libltdl-dev
.
MBDyn default linear solver, naive
, is very
reliable and very efficient
in solving the vast majority of the linear systems that MBDyn has to
tackle during the integration of multibody systems. However, it is always nice
to have alternatives available when things start to go South.
MBDyn has built-in support for some of the most widespread
(free)
linear solver packages available. Among them, I recommend to install the
SuiteSparse package,
providing the UMFPACK
and KLU
linear solvers.
You do this in Arch with
$ sudo pacman -S suitespase
and, as usual, in other distribution things might chance: it is libsuitesparse-dev
in Debian/Ubuntu, suitesparse-devel
in Fedora, etc...
Now that we have installed everything we need, we are ready to download the MBDyn source code, configure the package, and compile it.
Head over to the Gitlab repository page at
https://public.gitlab.polimi.it/DAER/mbdyn.
Dowload the repository code with the download button (left of the blue
Clone
button). It is recommended to first switch to the develop
branch, in order to obtain the most recent code. Download and extract the
archive, and cd into the MBDyn directory:
$ tar -xzf mbdyn-develop.tar.gz
$ cd mbdyn-develop/
Alternatively, if you have Git installed, you can clone the repository:
$ git clone https://public.gitlab.polimi.it/DAER/mbdyn.git
$ cd mbdyn/
by default, you will be placed on the develop
branch. If you want, you can
check that this is the case using git status
.
You first have to execute the bootstrap.sh
script, to generate the
configure scripts
& sh bootstrap.sh
Now you need to configure the package, using the just created
configure
script (you can copy and paste the whole command, or
copy everything in one line, removing the backslashes \
):
$ LDFLAGS="-rdynamic -lsuitesparseconfig" \
CPPFLAGS="-I/usr/include/suitesparse/" \
./configure \
--prefix=/usr/local \
--enable-netcdf=yes \
--with-umfpack=yes \
--with-lapack=yes \
--with-arpack=yes \
--with-module="hfelem muscles" \
--enable-runtime-loading
the choice of changing the prefix to /usr/local
is arbitrary: one can choose
to keep the default prefix /usr/local/mbdyn
and add the /usr/local/mbdyn/bin
directory to the systems' PATH
environment variable
(look here,
for example, for more information). This is setting the folder in which the
MBDyn binaries and libraries will be placed.
Also the choice of building the muscles
and hfelem
modules it is just an
example: you can choose which ones are of interest for you, or just remove
the --with-module=""
switch entirely if you do not wish to build any of them.
The configure script will output the result of a number of checks, designed to enable to proceed to the building phase only if the required software libraries are found, and to enable several optional functionalities if additional libraries are found:
$ ./configure
Configuring MBDyn Devel ...
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
[...]
config.status: creating build/Makefile
config.status: creating include/mbconfig.h
config.status: executing depfiles commands
config.status: executing libtool commands
If something goes wrong, errors will be raised. If instead the script does not find a library that is not strictly required, it will generally just raise a warning. If the configuration step is completed with success, you can proceed to build the package:
$ make -j4
note that the -jN
switch it is optional: it instructs make
to perform the
compilation in parallel mode, using N
instances in background. You can adjust
N
as you wish, with a good choice generally be the one to use the
number of cores of your CPU.
When the build is completed, you can install it (i.e. make the binaries available to every user from every location) with
$ sudo make install
Please notice that this command should be issued in superuser mode, if the
prefix is in one of the system's directories (that is the default behavior).
If you did not use the --prefix=/usr/local
option, then the MBDyn binaries
will be installed in /usr/local/mbdyn/bin
, which is not in the default PATH
of the distribution. Therefore, the mbdyn
command cannot yet be found
by the terminal in any location of the system. You can amend this by adding
the /usr/local/mbdyn/bin
directory to the default PATH
of your terminal.
For example, if you are using bash, you
can add this line to the .bashrc
file that is found in your home directory:
export PATH=${PATH}:/usr/local/mbdyn/bin
The change will take effect at the next session (a log-in, log-out should suffice), or you can force it to have immediate effect using this command
$ source ~/.bashrc
(this will have an effect on a single session of a single terminal window or tab).
Now you can check if everything went smoothly:
$ mbdyn -v
you should get something like this:
MBDyn - MultiBody Dynamics 1.7.3
configured on May 30 2024 at 10:42:17
MBDyn terminated normally
What follows is an eXperimental guide to install MBDyn in a
macOS environment. It is based on my experience in building and installing MBDyn on a
rather outdated machine, running OsX 10.15.7 and I don't currently have access to most
recent version of the OS1. Be careful that it is still possible
that with different versions of macOS YMMV, greatly.
These are the steps I've followed to compile MBDyn with LAPACK, (NetCDF), GiNaC, Suitesparse and runtime-loadable modules support.
This is the procedure that works for me:
- install Homebrew
IMPORTANT NOTE: it has been noted that the co-inhabitance of the XCode IDE and the CommandLine Tools is problematic to build software from source. If you already installed XCode, please skip the installation of the CommandLine Tools in the homebrew installation.
- install the following casks:
$ brew install autoconf automake ginac libtool m4 netcdf openblas suite-sparse lapack
- clone the mbdyn repository and switch to the
develop
branch:
$ git clone https://public.gitlab.polimi.it/DAER/mbdyn.git
$ cd mbdyn/
$ git checkout develop
-
IMPORTANT we will create a symbolic link to use GNU's Libtool (
glibtool
) instead of the default XCode one during the MBDyn build (remember to issue this command as superuser, for example preceding it withsudo
):
# ln -s /usr/local/bin/glibtool /usr/local/bin/libtool
# ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
- generate the configure scripts (from the MBDyn tree root
directory, i.e. the
mbdyn/
directory in which the repository was cloned at step 3. :
$ sh bootstrap.sh
- move outside of the
mbdyn/
directory and make a new directory for the build, for example called (you guessed it)build
$ cd ..
$ mkdir build/
$ cd build/
- from the
build/
directory, configure MBDyn, setting all required options for the C/C++ preprocessor (CPPFLAGS
), the linker (LDFLAGS
), pkgconfig (PKG_CONFIG_PATH
) and adding the modules (if any) you want to compile
$ CXXFLAGS="--std=c++14" CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib -lsuitesparseconfig" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ../mbdyn/configure --with-module="muscles hid hfelem" --enable-Werror=no
- if everything goes smoothly, build the package
$ make -j4
- if everything goes smoothly again, install MBDyn (again
with
sudo
or your preferred way to gain elevated privileges)
# make install
- add the MBDyn binaries folder to the system's
PATH
:
$ echo "export PATH=\${PATH}:/usr/local/mbdyn/bin" >> $HOME/.bash_profile
- test that you can call MBDyn now, after sourcing the
modified
.bash_profile
configuration:
$ . $HOME/.bash_profile
$ mbdyn -v
MBDyn - Multibody Dynamics develop
configured on Mar 1 2022 at 16:03:11
MBDyn terminated normally
- IMPORTANT remove the symbolic link that we created earlier (superuser privileges needed also here):
# rm /usr/local/bin/libtool
# rm /usr/local/bin/libtoolize
1: EDIT: thanks to the kind support of Neda Taymourtash, I've been now able to test that the procedure works also on a macOS 12.0.1 machine running clang 13.0.0 (XCode 13.2.1).