-
Notifications
You must be signed in to change notification settings - Fork 8
Installing MBDyn
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 could be also useful to highlight which is the recommended MBDyn configuration that allows to get the most out of Blendyn.
- MacOSX (tested on 10.15.7) installation guide (eXperimental: YMMV, greatly)
- Windows [>=10] installation guide
- GNU/Linux [Ubuntu] installation guide (same as before: what you do in the WSL is what you would do in an Ubuntu terminal)
- GNU/Linux [Arch] installation guide: follow along...
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.
If you are looking to install MBDyn on
In this guide I'll assume that you are working in a GNU/Linux environment. I'll use my currently preferred distribution, Arch (particularly its flavor Manjaro) 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
# pacman -S base-devel gcc-fortran
Please note that in all the terminal code listed in this page, the
$
prefix indicates commands to be issued as normal-user, while the#
prefix indicates that superuser privileges are needed.
Now you are ready to download the MBDyn code: 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/
You first have to execute the bootstrap.sh
script, to generate the
configure script
& sh bootstrap.sh
Now you need to configure the package, using the just created
configure
script, that is found in the root of the source code
$ ./configure --prefix=/usr/local
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).
The 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 --prefix=/usr/local
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.
When the build is completed, you can install it (i.e. make the binaries
available to every user from every location) with
# 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 still 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 Oct 22 2018 at 10:42:17
MBDyn terminated normally
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:
# 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 software that is compiled from source).
Once the NetCDF library has been installed, get back to the MBDyn folder and re-configure the package. If you want to force a check for the NetCDF library, use the following command:
$ ./configure --enable-netcdf=[legacy|netcdf4] --prefix=/usr/local
the --enable-netcdf=[legacy|netcdf4]
switch will force configure
to raise an
error if NetCDF is not found properly. Use legacy
or netcdf4
depending on
the version that you installed in your distribution. In the present
case, that would be netcdf4
.
After the configure step, you should re-build the package with make
and install it with make install
. Be aware that is not necessary to
build it before installing NetCDF: you can of course install this and
other optional libraries before making the first configuration.
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
# pacman -S lapack
Remember than in other distributions it might be needed to install the
development version of the library.
From now on, the procedure is the same as in the previous cases: re-configure
(optionally, force a strict check on LAPACK with
./configure --with-lapack=yes
), re-build (make
) and install (make install
)
the package.
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
# 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
.
To build a module (e.g. module-muscles
), you have to instruct
configure
accordingly:
$ ./configure --with-module=muscles --enable-runtime-loading
and as always, build (make
) and install (make install
) the package.
At the cost of being pedantic, I'll remind you that there is no need build the
package multiple times: you can
install all required and additional libraries before configuring MBDyn for
the first time. Remember also that the configure options can be combined, so
if you want to enable NetCDF output, runtime modules and the eigenanalysis
support, installing MBDyn in a folder that is already in the system's PATH
,
after having installed the related libraries listed in the previous sections
just use
$ ./configure --prefix=/usr/local --enable-netcdf=yes --with-lapack=yes \
--with-module=muscles --enable-runtime-loading
and then if all goes smoothly build (make
) and install (make install
) the
package, as usual.
What follows is an eXperimental guide to install MBDyn in a MacOsX 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 OS. Therefore, be careful that with different versions of OsX 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
- 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