buildozer+Cyton+C++库:dlopen失败:找不到module.so引用的符号符号名称



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

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

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++'],
)])
)

我做错了什么?

首先,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()

相关内容

  • 没有找到相关文章

最新更新