Installing JModelica.org on CentOS 7 - make casadi_interface fails due to wrong interpretation of Python include paths

1 post / 0 new
Łukasz_Dudek
Offline
Joined: 2017-04-04
Installing JModelica.org on CentOS 7 - make casadi_interface fails due to wrong interpretation of Python include paths

Hello!

I've very recently stumbled across JModelica.org and found it perfect for my needs in terms of calculating time-optimal control for non-linear systems.

I've tried installing it on CentOS 7 with a self-compiled Python installation. I've been able to use PYTHON_HOME=/opt/python to specify it so compilation and installation of JModelica.org went without any issues.

I've encountered a problem with make casadi_interface command - it couldn't find Python.h - which, of course, is there in Python include directory. I've examined options presented in the output and I've found:

-DPYTHON_INCLUDE_DIR=/opt/python/include

It's not a correct path to Python includes. They're in /opt/python/include/python2.7 - no wonder that the compilation of casadi_interface failed.

Moreover, I've used a dirty hack to bypass the problem - I've symlinked everything under /opt/python/include/python2.7 to /opt/python/include. Unfortunately, that wasn't the end of the problem. I've found that Python shared object that JModelica tires to use is called:

-DPYTHON_LIBRARY=/opt/python/libs/libpython27.a

It's not present, it should be /opt/python/lib/libpython2.7.a

Again, I've used a symlink to bypass that, but unfortunately, I've got another problem:

/usr/bin/ld: /opt/python/libs/libpython27.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC

Please find the whole output of the last running of make casadi_interface attached to this post. Does the error mean that I've got to recompile my Python?

 

TL;DR: I think there are bugs in interpretation of Python include and lib directories when JModelica is given a PYTHON_HOME env variable. Also, a question: does the last compilation error mean that I have to recompile my Python installation?

 

EDIT: I've recompiled my Python and it worked - now I have a working installation of JModelica and I'm able to run examples. I've used the following configure for Python:

CXXFLAGS=-fPIC ../configure --enable-shared --prefix=/opt/python --with-cxx-main=g++ --enable-unicode=ucs4 --with-pth --with-ensurepip=upgrade --with-valgrind

The possible bugs with paths are still present and may require someone's attention.