1

phase_engine.so尝试使用_ZTINSt6__ndk18ios_base7failureE但找不到它:

11-08 19:59:00.629 25777 25823 I python  :  Traceback (most recent call last):
11-08 19:59:00.629 25777 25823 I python  :    File "/home/sonoflilit/phase/phase/.buildozer/android/app/main.py", line 14, in <module>
11-08 19:59:00.629 25777 25823 I python  :  ImportError: dlopen failed: cannot locate symbol "_ZTINSt6__ndk18ios_base7failureE" referenced by "/data/data/il.co.loris.phase/files/app/_python_bundle/site-packages/phase_engine.so"...
11-08 19:59:00.630 25777 25823 I python  : Python for android ended.

它存在于libc++_shared.so

apk$ readelf -s --wide lib/armeabi-v7a/libc++_shared.so | grep _ZTINSt6__ndk18ios_base7failureE
   690: 000885c0    12 OBJECT  GLOBAL DEFAULT   17 _ZTINSt6__ndk18ios_base7failureE

哪个不是动态链接的phase_engine.so

apk/assets$ readelf -a _python_bundle/site-packages/phase_engine.so | grep lib
 0x00000001 (NEEDED)                     Shared library: [libpython3.8m.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so]
 0x00000001 (NEEDED)                     Shared library: [libc.so]
  000000: Rev: 1  Flags: BASE  Index: 1  Cnt: 1  Name: build/lib.linux-x86_64-3.8/phase_engine.cpython-38-x86_64-linux-gnu.so
  000000: Version: 1  File: libc.so  Cnt: 1
  0x0020: Version: 1  File: libdl.so  Cnt: 1

尽管我很好地询问了libraries = ['c++'],in setup.py(肯定会运行):

from setuptools import setup, Extension
from Cython.Build import cythonize

setup(
    name = 'phase-engine',
    version = '0.1',
    ext_modules = cythonize([Extension("phase_engine",
        ["phase_engine.pyx"] + ['music-synthesizer-for-android/src/' + p for p in [
            ..., 'synth_unit.cc'
        ]],
        include_path = ['music-synthesizer-for-android/src/'],
        language = 'c++',
        libraries = ['c++'],
    )])
)

我究竟做错了什么?

4

1 回答 1

1

首先,这c++当然应该是c++_shared,因为调用了库libc++_shared.so

其次,我无法让它与setup.py.numpy

class MyRecipe(IncludedFilesBehaviour, CppCompiledComponentsPythonRecipe):
    version = 'stable'
    src_filename = "../../../phase-engine"
    name = 'phase-engine'

    depends = ['setuptools']

    call_hostpython_via_targetpython = False
    install_in_hostpython = True

    def get_recipe_env(self, arch):
        env = super().get_recipe_env(arch)
        env['LDFLAGS'] += ' -lc++_shared'
        return env

recipe = MyRecipe()
于 2020-11-09T16:03:08.323 回答