Tried to obtain MA57 from shared library "libhsl.dylib"

855 views
Skip to first unread message

Mike

unread,
Aug 24, 2016, 6:59:36 PM8/24/16
to CasADi
Hi,

I am on a Mac using precompiled Casadi version for Matlab 2015a. After successful compilation of hsl libraries,  I did create the symlink between  libcoinhsl.dylib  and libhsl.dylib and also did set the environment variable DYLD_LIBRARY_PATH in .bashrc as well as inside Matlab. Still, it is complaining of not finding the ma57 solver.

Error message:

 Exception message: Selected linear solver MA57 not available.
Tried to obtain MA57 from shared library "libhsl.dylib", but the following error occured:
dlopen(libhsl.dylib, 2): image not found

Could you please help me out?

Best,

Mike.

Joel Andersson

unread,
Aug 26, 2016, 12:18:48 PM8/26/16
to CasADi
Hi Mike!

Joris probably knows more about this, but can you try putting that symlink in the same directory as the CasADi/IPOPT library? IIRC, MATLAB does not honor any set system paths.

Joel

Mike

unread,
Aug 26, 2016, 2:27:23 PM8/26/16
to CasADi

Hi Joel,

Solved it. You were right, this is what I did:

created a symlink to hsl libraries to casadi folder like this;

ln -s /(coin hsl installation folder)/build/lib/libcoinhsl.dylib /casadi_precompiled_folder)/libhsl.dylib

After this next error that might pop up is this:

Symbol not found: __gfortran_transfer_array_write
Referenced from:/casadi_precompiled_folder)/libhsl.dylib
Expected in: /Applications/MATLAB_R20__.app

To fix that: Do the following:

Go to:
cd  /Applications/MATLAB_R20__.app/bin/
open .matlab7rc.sh in your favourite text editor:

And follow the instructions in this page: http://issm.jpl.nasa.gov/documentation/faq/matlab/

Mike

unread,
Aug 26, 2016, 2:44:06 PM8/26/16
to CasADi
Also since you don't get precompiled hsl libraries for mac, you will have to compile it, there are couple of things you need to take care while compiling.

It would be good if you add these to your page where you explain how to compile it.

These are what I did:

Step 1: Unpack hsl source files.
Step 2: inside the hsl source folder, 
  1.  $wget http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/OLD/metis-4.0.3.tar.gz
  2.  $tar -xvf metis-4.0.3.tar.gz
Step 3: $./configure --prefix=(where_you_want_to_install) LIBS="-llapack" --with-blas="-L/usr/lib -lblas" CXXFLAGS="-g -O2 -fopenmp" FCFLAGS="-g -O2 -fopenmp" CFLAGS="-g -O2 -fopenmp"
Problems you can face here are these. These are specific to mac.

Error:
checking for Fortran 77 libraries of /usr/local/bin/gfortran...
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0/../../..
-llapack -lgfortran -lgomp -lquadmath -lm
checking for dummy main to link with Fortran 77 libraries... unknown
configure: error: in `/home/coinhsl/build':
configure: error: linking to Fortran libraries from C fails

Solution:

By default, mac is configured with clang and the option "-fopenmp" is not recognised by it. Though you have gcc installed it might not be default compiler or may not even exist. The solution is this.

$brew install gcc49

After this in your .bashrc file, add following lines.

export CC=/usr/local/bin/gcc-4.9
export CXX=/usr/local/bin/g++-4.9
export CPP=/usr/local/bin/cpp-4.9
export LD=/usr/local/bin/gcc-4.9
alias c++=/usr/local/bin/c++-4.9
alias g++=/usr/local/bin/g++-4.9
alias gcc=/usr/local/bin/gcc-4.9
alias cpp=/usr/local/bin/cpp-4.9
alias ld=/usr/local/bin/gcc-4.9
alias cc=/usr/local/bin/gcc-4.9

Rerun Step 3:
Step 4: $make
Step 5: $make install
Step 6: symlink libcoinhsl.dylib to casadi installation folder as libhsl.dylib
Step 7: Follow previous comment if you get the __gfortran_transfer_array_write error.

bsutter

unread,
Nov 11, 2016, 4:00:07 AM11/11/16
to CasADi

Minor extension to Mike's guide:

I used gcc6, obtained via MacPorts to compile the library and had to change a few things.

1.)
MacPorts default installation directory is /opt/local/, so the exports and alias' in your .bashrc have to be set accordingly, e.g.
alias g++=/opt/local/bin/g++-mp-6

2.)
If you didn't set your default compiler to gcc6 using
port select --set gcc gcc6
create a symlink for gfortran:
ln -s /opt/local/bin/gfortran-mp-6 /opt/local/bin/gfortran

3.)
For some reason, in my configure step, the option --with-blas was not recognized and configure threw a warning (if anyone could shed some light on why this is happening I'd be really interested!). My solution was to just omit this option in the ./configure step.

For the rest of the installation, refer to Mike's guide.

Hope this helps

bsutter

unread,
Nov 12, 2016, 5:36:28 AM11/12/16
to CasADi
Update to my extension:

In step 3.), the --with-blas option should only be ommited if you're compiling the library for personal use (containing solvers ma27, ma28 and mc19).
If you're compiling the full HSL library (available for free only for academic use), the option is needed for configuration!

Sorry for the confusion, best regards. 


Reply all
Reply to author
Forward
0 new messages