linux cython 编译32位 so (报错 xxx.so is 64-bit instead of 32-bit)

系统是 Ubuntu 64位,默认编译出来的 so 是 x64的。放手机上无法运行提示:

I/python (14633): ImportError: dlopen failed: "/data/data/com.myapp.xytest/file
s/app/lib/python2.7/site-packages/core.so" is 64-bit instead of 32-bit

安装32位环境:

 apt-get install lib32readline-dev

修改 setup.py 主要是增加 "-fopenmp","-m32" 两个编译参数

#!/usr/bin/python
#python version: 2.7.3
#Filename: SetupTestOMP.py

# Run as:
# python setup.py build_ext –inplace

import sys
sys.path.insert(0, "..")

from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext

# ext_module = cythonize("core.py")
ext_module = Extension(
"core",
["core.py"],
extra_compile_args=["-fopenmp","-m32"],
extra_link_args=["-fopenmp","-m32"],
)

setup(
cmdclass = {‘build_ext’: build_ext},
ext_modules = [ext_module],
)

 

but 编译出来的是 x86 的 .so 依旧无法在 arm 平台运行 报错:

I/python (15055): ImportError: dlopen failed: "/data/data/com.myapp.xytest/file
s/app/lib/python2.7/site-packages/core.so" has unexpected e_machine: 3

发表评论

您的电子邮箱地址不会被公开。