{"id":95,"date":"2009-12-16T05:58:00","date_gmt":"2009-12-16T05:58:00","guid":{"rendered":"https:\/\/sandrock.co.za\/carl\/2009\/12\/16\/building-jmodelica-on-mac-os-x-snow-leopard\/"},"modified":"2009-12-16T05:58:00","modified_gmt":"2009-12-16T05:58:00","slug":"building-jmodelica-on-mac-os-x-snow-leopard","status":"publish","type":"post","link":"https:\/\/sandrock.co.za\/carl\/2009\/12\/building-jmodelica-on-mac-os-x-snow-leopard\/","title":{"rendered":"Building JModelica on Mac OS X Snow Leopard"},"content":{"rendered":"<p>I am again working on my PhD and I need to get my development environment sorted out.  I have almost had it with <a href=\"http:\/\/openmodelica.org\/\">OpenModelica<\/a>, 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 <a href=\"http:\/\/www.jmodelica.org\/\">JModelica<\/a> instead.  I duly followed the start of the <a href=\"http:\/\/www.jmodelica.org\/book\/106\">install instructions<\/a>, including grabbing a version of the repository using svn (I was not warned that the repo is about 130 MiB, though!).  <\/p>\n<div><\/div>\n<div>\n<h1>Installing Ipopt<\/h1>\n<p><a href=\"http:\/\/www.coin-or.org\/Ipopt\/\">Ipopt<\/a> is an interior point solver, part of the COIN-OR project.  JModelica includes some nifty optimisation functionality via <a href=\"http:\/\/www.jmodelica.org\/faq\/18\">Optimica<\/a> so it is quite good to have Ipopt (even though it is not required).  So I download the latest Ipopt tarball and now I&#8217;m faced with more dependancies: <a href=\"http:\/\/www.netlib.org\/blas\/\">BLAS<\/a> and <a href=\"http:\/\/www.netlib.org\/lapack\/\">LAPACK<\/a>.  After some toying around with these packages, I learned the following:<\/div>\n<div>\n<ul>\n<li>The Mac dev tools inclode cBLAS and cLAPACK as part of the <a href=\"http:\/\/developer.apple.com\/hardwaredrivers\/ve\/vector_libraries.html\">vecLib framework<\/a> (something to remember).  However, these <a href=\"http:\/\/www.macresearch.org\/lapackblas-fortran-106\">don&#8217;t play well with gfortran on 10.6<\/a><\/li>\n<li>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.<\/li>\n<li>Ipopt actually has scripts for downloading these for compiling Ipopt, as documented <a href=\"http:\/\/www.coin-or.org\/Ipopt\/documentation\/node15.html\">here<\/a> (although, crucially, not in the install documentation I was following in the distribution)<\/li>\n<li>The Ipopt instructions advise using the HSL libraries, but the process you have to go through to get them takes time, I&#8217;ve done it, but I still don&#8217;t have access, so I&#8217;m just going for Mumps instead.<\/li>\n<\/ul>\n<div>So, after wasting much time, all I really needed to do was<\/div>\n<pre><span style=\"font-family:Georgia, serif;font-size:130%\"><span style=\"font-size:16px\"><br \/><\/span><\/span>cd ThirdParty<br \/>for lib in Blas Lapack ASL Metis Mumps; do<br \/>cd $lib;<br \/>.\/get.$lib<br \/>cd ..<br \/>done<br \/>cd ..<br \/>.\/configure --prefix=\/usr\/local # to get stuff where I want it<br \/>make<br \/><\/pre>\n<div><\/div>\n<div><\/div>\n<div>Well, after that the configure script worked, but there was a build error (or a couple of them, all with the same form):<\/div>\n<p><\/p>\n<pre><br \/>lpBlas.cpp:211: error: \u2018dtrsm\u2019 was not declared in this scope<br \/>IpBlas.cpp:211: error: \u2018DTRSM\u2019 was not declared in this scope<br \/>IpBlas.cpp:211: error: \u2018F77_FUNC\u2019 cannot be used as a function<br \/><\/pre>\n<p><\/p>\n<div>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 &#8220;#define F77_FUNC&#8221;) shows that it&#8217;s supposed to be a mangling thing.  Even further investigation shows that one of the configure messages that wizzed by is &#8220;WARNING: unknown Fortran name-mangling scheme&#8221;).  The configure script then just silently doesn&#8217;t define F77_FUNC, leading to these errors.  After scrutinising <\/p>\n<pre>Ipopt\/config.log<\/pre>\n<p> I noticed that ld was complaining about the archetecture.  I modify my call to configure thus: <\/p>\n<pre>FFLAGS=\"-arch=x86_64\"<\/pre>\n<p>Now make runs!  Make test succeeds and I can do <\/p>\n<pre>sudo make install<\/pre>\n<p> and get to the main game.<\/p><\/div>\n<div><\/div>\n<p><\/p>\n<h1>Building JModelica<\/h1>\n<p><\/p>\n<div>So, back to the original build instructions.  I modify the configure again to point to the right places.<\/p>\n<pre><br \/>cd JModelica<br \/>mkdir build<br \/>cd build<br \/>..\/configure --with-ipopt=\/usr\/local\/ --prefix=\/usr\/local<br \/>make<br \/><\/pre>\n<p><\/div>\n<p>Three minutes later, success!  Now do build docs (which requires doxygen, obtained via fink and <a href=\"http:\/\/www.graphviz.org\/\">graphviz<\/a>, using the <a href=\"http:\/\/www.graphviz.org\/Download_macos.php\">Mac install package<\/a>), which takes ages.<\/div>\n<div><\/div>\n<p><\/p>\n<h1>Python support<\/h1>\n<p><\/p>\n<div>Last step is getting Python support, one of the other cool things about JModelica.    The docs list the following packages:<\/p>\n<table>\n<tbody>\n<tr>\n<th>Package<\/th>\n<th>URL<\/th>\n<th>Steps I took to install<\/th>\n<\/tr>\n<tr>\n<td>JPype<\/td>\n<td>http:\/\/jpype.sourceforge.net\/<\/td>\n<td>Download, run sudo python setup.py install<\/td>\n<\/tr>\n<tr>\n<td>lxml<\/td>\n<td>http:\/\/codespeak.net\/lxml\/<\/td>\n<td>sudo easy_install lxml<\/td>\n<\/tr>\n<tr>\n<td>NumPy 1.2.0<\/td>\n<td>http:\/\/numpy.scipy.org\/<\/td>\n<td>Already installed<\/td>\n<\/tr>\n<tr>\n<td>Scipy 0.7<\/td>\n<td>http:\/\/www.scipy.org\/<\/td>\n<td>Already installed<\/td>\n<\/tr>\n<tr>\n<td>PySundials 2.3<\/td>\n<td>http:\/\/sourceforge.net\/projects\/pysundials\/<\/td>\n<td>Install <a href=\"https:\/\/computation.llnl.gov\/casc\/sundials\/main.html\">SUNDIALS<\/a>, change reference in  src\/sundials_core_aux.c from sundials\/sundials_smalldense.h to sundials\/sundials_dense.h. sudo python setup.py install<\/td>\n<\/tr>\n<tr>\n<td>pyreadline =1.5<\/td>\n<td>http:\/\/ipython.scipy.org\/dist\/<\/td>\n<td>sudo easy_install pyreadline<\/td>\n<\/tr>\n<tr>\n<td>Matplotlib<\/td>\n<td>http:\/\/matplotlib.sourceforge.net\/<\/td>\n<td>already installed<\/td>\n<\/tr>\n<tr>\n<td>Nose<\/td>\n<td>http:\/\/code.google.com\/p\/python-nose\/<\/td>\n<td>sudo easy_install nose<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>And now it still doesn&#8217;t work, because Matplotlib is causing segfaults.  I guess it&#8217;s time to call it a day &#8212; more in getting Matplotlib to go tomorrow.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sandrock.co.za\/carl\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sandrock.co.za\/carl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sandrock.co.za\/carl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sandrock.co.za\/carl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sandrock.co.za\/carl\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":0,"href":"https:\/\/sandrock.co.za\/carl\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"wp:attachment":[{"href":"https:\/\/sandrock.co.za\/carl\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sandrock.co.za\/carl\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sandrock.co.za\/carl\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}