Building JModelica on Mac OS X Snow Leopard

Written by

in

I am again working on my PhD and I need to get my development environment sorted out. I have almost had it with OpenModelica, because it is so hard to get going on my Mac. I have tried to contribute code to the build process, but the configure script still bombs out based on environment variables that have to be set by hand and so forth. I have therefore decided to try JModelica instead. I duly followed the start of the install instructions, including grabbing a version of the repository using svn (I was not warned that the repo is about 130 MiB, though!).

Installing Ipopt

Ipopt is an interior point solver, part of the COIN-OR project. JModelica includes some nifty optimisation functionality via Optimica so it is quite good to have Ipopt (even though it is not required). So I download the latest Ipopt tarball and now I’m faced with more dependancies: BLAS and LAPACK. After some toying around with these packages, I learned the following:

  • The Mac dev tools inclode cBLAS and cLAPACK as part of the vecLib framework (something to remember). However, these don’t play well with gfortran on 10.6
  • You can download and build them yourself with little effort, but most build tools assume you are going to use -lblas to access it, which is a bit harder to override.
  • Ipopt actually has scripts for downloading these for compiling Ipopt, as documented here (although, crucially, not in the install documentation I was following in the distribution)
  • The Ipopt instructions advise using the HSL libraries, but the process you have to go through to get them takes time, I’ve done it, but I still don’t have access, so I’m just going for Mumps instead.
So, after wasting much time, all I really needed to do was

cd ThirdParty
for lib in Blas Lapack ASL Metis Mumps; do
cd $lib;
./get.$lib
cd ..
done
cd ..
./configure --prefix=/usr/local # to get stuff where I want it
make
Well, after that the configure script worked, but there was a build error (or a couple of them, all with the same form):


lpBlas.cpp:211: error: ‘dtrsm’ was not declared in this scope
IpBlas.cpp:211: error: ‘DTRSM’ was not declared in this scope
IpBlas.cpp:211: error: ‘F77_FUNC’ cannot be used as a function

Looking at the source, it was clear that F77_FUNC was supposed to be a macro that helps with fortran execution or something. Further investigation (grep -R “#define F77_FUNC”) shows that it’s supposed to be a mangling thing. Even further investigation shows that one of the configure messages that wizzed by is “WARNING: unknown Fortran name-mangling scheme”). The configure script then just silently doesn’t define F77_FUNC, leading to these errors. After scrutinising

Ipopt/config.log

I noticed that ld was complaining about the archetecture. I modify my call to configure thus:

FFLAGS="-arch=x86_64"

Now make runs! Make test succeeds and I can do

sudo make install

and get to the main game.

Building JModelica

So, back to the original build instructions. I modify the configure again to point to the right places.


cd JModelica
mkdir build
cd build
../configure --with-ipopt=/usr/local/ --prefix=/usr/local
make

Three minutes later, success! Now do build docs (which requires doxygen, obtained via fink and graphviz, using the Mac install package), which takes ages.

Python support

Last step is getting Python support, one of the other cool things about JModelica. The docs list the following packages:

Package URL Steps I took to install
JPype http://jpype.sourceforge.net/ Download, run sudo python setup.py install
lxml http://codespeak.net/lxml/ sudo easy_install lxml
NumPy 1.2.0 http://numpy.scipy.org/ Already installed
Scipy 0.7 http://www.scipy.org/ Already installed
PySundials 2.3 http://sourceforge.net/projects/pysundials/ Install SUNDIALS, change reference in src/sundials_core_aux.c from sundials/sundials_smalldense.h to sundials/sundials_dense.h. sudo python setup.py install
pyreadline =1.5 http://ipython.scipy.org/dist/ sudo easy_install pyreadline
Matplotlib http://matplotlib.sourceforge.net/ already installed
Nose http://code.google.com/p/python-nose/ sudo easy_install nose

And now it still doesn’t work, because Matplotlib is causing segfaults. I guess it’s time to call it a day — more in getting Matplotlib to go tomorrow.

Comments

  1. Unknown Avatar

    In order to set up a clean Python distro with all the JModelica.org Python deps I used MacPorts (www.macports.org). Having installed Python 2.6, numpy, scipy, matplotlib, ipython and lxml were available through macports. JPype I had to install manually.

  2. matthis Avatar

    Hi, have you rerun these steps lately, would they still work? Or do you know about a recent installation guide? Thanks!

  3. Foad Avatar

    Dicord chatroom for Modelica Language, OpenModelica, JModelica, Dymola, Wolfram SystemModeler, MapleSim…

    https://discord.gg/bp2yeYU

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.