[Mobile-sig] [Python-Dev] Import Fails in setup.py On Android

Cyd Haselton chaselton at gmail.com
Wed Feb 18 02:08:25 CET 2015



On February 17, 2015 4:58:41 PM CST, "Frank, Matthew I" <matthew.i.frank at intel.com> wrote:
>On Tuesday, February 17, 2015 4:40 PM, Cyd Haselton wrote:
>> Some additional import failures.  I;ve compared build instructions
>for these modules
>> and can't find anything that stands out as to why one module will
>import and the other
>> doesn't:
>[...]
>> ImportError: dlopen failed: cannot locate symbol "PyErr_BadArgument"
>referenced by
>> "array.cpython-34m.so"...
>[...]
>> ImportError: dlopen failed: cannot locate symbol "PyMem_Malloc"
>referenced by
>> "_random.cpython-34m.so"...
>[...]
>> ImportError: dlopen failed: cannot locate symbol "PyMem_Malloc"
>referenced by
>> "zlib.cpython-34m.so"...
>[...]
>> ImportError: dlopen failed: cannot locate symbol "PySequence_GetItem"
>referenced by
>> "_bisect.cpython-34m.so"...
>[...]
>> ImportError: dlopen failed: cannot locate symbol "PyErr_SetNone"
>referenced by
>> "_pickle.cpython-34m.so"...
>
>All those missing symbols are defined in libpython3.4m.so.  I suspect
>that array.cpython-34m.so, _random.cpython-34m.so, zlib.cpython-34m.so,
>_bisect.cpython-34m.so and _pickle.cpython-34m.so were all compiled
>without the correct -lpython3 flag.  I suspect that some other imports
>are not displaying this problem because, although they also are not
>compiled with -lpython3, they aren't trying to access symbols from
>libpython3.4m.so.
>

Interesting.  I'll add -lpython3.4m to one of the setup.py built extensions to see if that resolves the issue.

>If I'm correct, the problem here is with Android's broken dlopen().  On
>Linux (and every other Unix I'm aware of) when Executable A links B
>then tries to dlopen C, if C needs to access symbols from B it just
>succeeds (whether or not you linked C with "-lB".)  On Android you
>_must_ link C against "-lB" for this to work.  This is a known bug in
>Android's loader and won't be fixed, because the supposed security
>advantages of not accidentally linking something you didn't mean to
>link supposedly outweigh the disadvantages of not being able to
>correctly compile linux packages for Android.

I can vaguely understand this rational, given Android is not Linux and wasn't really designed to be used in the way I'm attempting, but it doesn't make it any less annoying.
>
>I ran into only a few instances of these when getting Python 3.4 to
>cross compile to Android, and none with missing -lpython3 flags (most
>were missing -lm flags).  But I'm not running setup.py on the Android
>side.  I'm running on it the Linux host (using the Python interpreter
>on the Linux host.)
>
>-Matt

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


More information about the Mobile-sig mailing list