MBDyn sim suite
Building MBDyn bindings on a win32 system
Those instructions will built MBDyn as a service that can be controlled from Python. That's why the term of bindings is used. The first step will be to enter in the 'bindings' directory: # cd bindingsGetting MBDyn source
This package is based on the 1.2.7 version of MBDyn, just some modifications are done for running MBDyn in a script language philosophy. You can get the source there and save them in the current 'bindings' directory.Decompress the archive
The following line assumes that you are in the current 'bindings' directory. As MSYS is installed, you can use the following command: # tar xvzf mbdyn-1.2.7.tar.gzPatch the sources
Displace the 'win32.patch' into the 'mbdyn-1.2.7' directory: # mv win32.patch mbdyn-1.2.7Enter the 'mbdyn-1.2.7' directory: # cd mbdyn-1.2.7
It is needed to enter the shell for patching the sources: # sh
The sources can now be patched: # patch -p1 < win32.patch
Go out of the shell: # exit
Come back to the current directory: # cd ..
Customize your build (optional)
You can edit it 'custom.py' for adjusting the construction options. By default the mbdyn executable will be installed in the same place as the 'python.exe' command, so then it is sure that 'mbdyn.exe' will be found when the system looks in the 'Path' variable. Moreover the path of the 'sh.exe' command may have to be adjusted according to your installation. As a resume, the two variables that could be checked first are:- BIN_PREFIX
- SH_SHELL
Configure the project
Run SCons for the configuration. # scons conf=1This process should create the files 'libs_config.pickle' in the current directory as well as 'mbconfig.h' and 'mbdefs.h' in the 'mbdyn-1.2.7/include' directory.
Getting the MBDyn Executable (Optional)
A native win32 version of MBDyn can be built by: # scons bin=1However the executable obtained will also failed for long input file, the same problem is encountered for the MBDyn executable as for the MBDyn service. The problem should come from the source modification by the 'win32.patch'.
The installation is achieved by: # scons install
Getting the MBDyn service for Python
From that step, the modifications of the MBDyn source will be applied for allowing a control from Python. An extra 'SWIG' definition is passed to the compiler, moreover the directory containing the changes, 'swig_interface/mbdyn_modifications', is always given as the first include directory. The huge win32 problem is that a shared library can obviously not be built with undefined symbols (unless specified by a Microsoft syntax: 'dllexport', 'dllimport' and so on). It means that the dynamic link between the MBDyn shared library and the SWIG module can not be done anymore (unless writing the MBDyn sources for win32), everything has to be built into one shared library. This is an import disadvantage for the development, Scons has always to scan for all the sources for just one line changed in SWIG part.The most important part of the build process is achieved by: # scons win32=1
Another problem encountered on win32 was with the command prompt. This last one is limited to a value that did not allow to pass all the compiled sources to the linker. This problem has been solved by using 'sh.exe' and modifying the Scons command (have a look to 'SPAWN' variable in the 'SConstruct' file if you are interested about it).
Then the bindings can be built, including the remaining MBDyn modifications, by: # scons win32link=1
It should produce a file, '_swigModule.pyd' that include the whole MBDyn shared library and 'swigModule.py' is the Python interface created by SWIG. The installation to the package source is done by: # scons win32_install_ext
Back to the Python Package
This is time to install the package as MBDyn is now available as a Python service. Change the current directory: # cd ..Build and install the Python package.