reaktoro / optima

A C++/Python library for numerical optimization calculations
GNU Lesser General Public License v2.1
12 stars 8 forks source link

ImportError cannot locate symbol "PyCapsule_Type" #20

Closed defencedog closed 1 year ago

defencedog commented 1 year ago

I have successfully compiled & installed the git version; but when I import optima library in ipython this happens

In [1]: import optima
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-6df14caa3eef> in <cell line: 1>()
----> 1 import optima

/data/data/com.termux/files/usr/lib/python3.9/site-packages/optima/__init__.py in <module>
----> 1 from optima.optima4py import *

ImportError: dlopen failed: cannot locate symbol "PyCapsule_Type" referenced by "/data/data/com.termux/files/usr/lib/python3.9/site-packages/optima/optima4py.cpython-39.so"...

There is no missing library as well

~ $ ldd "/data/data/com.termux/files/usr/lib/python3.9/site-packages/optima/optima4py.cpython-39.so"
        libOptima.so => /data/data/com.termux/files/usr/local/lib/libOptima.so
        libc++_shared.so => /data/data/com.termux/files/usr/lib/libc++_shared.so
        libdl.so => /system/lib64/libdl.so
        libm.so => /data/data/com.termux/files/usr/lib/libm.so
        libc.so => /system/lib64/libc.so
        ld-android.so => /system/lib64/ld-android.so

My cmake configure log

~/optima/build_aarch64 $ cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX/local
-- CCache: Could not find ccache. Install it to speed up the build operation.
-- The CXX compiler identification is Clang 15.0.4
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /data/data/com.termux/files/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Eigen3: /data/data/com.termux/files/usr/share/eigen3/cmake (found version "3.4.0")
-- Found PythonInterp: /data/data/com.termux/files/usr/bin/python3 (found suitable version "3.9.15", minimum required is "3.6")
-- Found PythonLibs: /data/data/com.termux/files/usr/lib/libpython3.9.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Performing Test HAS_FLTO_THIN
-- Performing Test HAS_FLTO_THIN - Success
-- Found pybind11: /data/data/com.termux/files/usr/include (found version "2.10.1")
-- Configuring done
-- Generating done
-- Build files have been written to: /data/data/com.termux/files/home/optima/build_aarch64

Plz note that as mentioned in homepage of git this flag is no longer applicable -DINSTALL_PATH=$PREFIX/local

defencedog commented 1 year ago

Ok done, on Android this way results no symbol errors

git clone https://github.com/reaktoro/optima.git
cd optima && mkdir build_aarch64
cd build_aarch64

I have python 3.9 from TUR repo

export LDFLAGS=-lpython3.9 && MATHLIB=m cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX/local

then in build directory

cd /data/data/com.termux/files/home/optima/build_aarch64/python/package
pip install .