Search code examples
jmodelica

JModelica refuses to load libhsl.so


JModelica is refusing to load the file libhsl.so as a shared library, even though I have set the LD_LIBRARY_PATH variable:

Exception of type: OPTION_INVALID in file "../../../../Ipopt/src/Algorithm/IpAlgBuilder.cpp" at line 321: Exception message: Selected linear solver MA27 not available. Tried to obtain MA27 from shared library "libhsl.so", but the following error occured: libhsl.so: cannot open shared object file: No such file or directory

I have tried recompiling and rerunning JModelica in many ways.

I have set LD_LIBRARY_PATH appropriately.

I have run ldconfig.

Nothing seems to help.

How can I fix this?


Solution

  • As of revision 7885 of the JModelica trunk, JModelica egregiously violates the Principle of Least Astonishment.

    JModelica suggest you use the script /usr/local/jmodelica/bin/jm_python.sh or what have you to run your JModelica code.

    Digging inside of this script, we find the following line:

    LD_LIBRARY_PATH=:/root/Ipopt-3.12.4/build/lib/:/usr/local/jmodelica/ThirdParty/Sundials/lib:/usr/local/jmodelica/ThirdParty/CasADi/lib \
    

    Note that LD_LIBRARY_PATH is being overwritten, so it does not matter what you set it as!

    Changing this line to:

    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/Ipopt-3.12.4/build/lib/:/usr/local/jmodelica/ThirdParty/Sundials/lib:/usr/local/jmodelica/ThirdParty/CasADi/lib \
    

    resolves the issues.

    This was brought up as a user patch on JModelica's site here on 2015-05-03. A patch was submitted on circa Revision 8185 to fix the issue, but it continued to crop up for me on trunk after that.