How to use Android NDK to compile Numpy as .so?

2024/10/11 16:27:44

Because the Numpy isn't a static library(it contains .py files, .pyc files, .so files, etc), so if I want to import it to my python code which is used in an Android phone(using CLE), I should recompile the library as a .so file. I have found that if I want to use NDK to compile it, I should have an Application.mk and an Android.mk files. But I don't know how to create these files.

How can I compile the Numpy library or anyone could give me a useful website.

Thanks a lot.

Answer

I should have an Application.mk and an Android.mk files.

This is the older way of Android JNI programming, the current recommended style is to use CMake for NDK development.

If you just want a working example and do modification based on it, then you can find one from here: https://github.com/russell-shizhen/JniExample

I should recompile the library as a .so file

In order to recompile, you need its source code for sure. Without source code, you can only try to link those existing static libs to form your own .so lib.

https://en.xdnf.cn/q/118304.html

Related Q&A

passing boolean function to if-condition in python

I"m learning python, and Im trying to do this, which I thought should be trivial, but apparently, its not. $python >>> def isTrue(data): ... "ping" in data ... >>>…

Unsupported operand type(s) for str and str. Python

Ive got the IF statement;if contactstring == "[Practice Address Not Available]" | contactstring == "[]":Im not sure what is going wrong(possibly the " "s?) but I keep ge…

getting Monday , june 5 , 2016 instead of June 5 ,2016 using DateTimeField

I have an app using Django an my my model has the following field: date = models.DateTimeField(auto_now_add=True,auto_now=False)Using that I get this: June 5, 2016, 9:16 p.m.but I need something like…

WeasyPrint usage with Python 3.x on Windows

I cant seem to get WeasyPrint to work on Windows with Python 3.4 or 3.5. Has anyone been able to do this? There arent forums at weasyprint.org and the IRC channel is dead. Ive been able to install …

matplotlib scatter array lengths are not same

i have 2 arrays like this x_test = [[ 14. 1.] [ 14. 2.] [ 14. 3.] [ 14. 4.] [ 14. 5.] [ 14. 6.] [ 14. 7.] [ 14. 8.] [ 14. 9.] [ 14. 10.] [ 14. 11.] [ 14. 12.]]y_test = [ 254.7 255…

APLpy/matplotlib: Coordinate grid alpha levels for EPS quality figure

In the normal matplotlib axes class, it is possible to set gridlines to have a certain transparency (alpha level). Im attempting to utilise this with the APLpy package using the following:fig = pyplot.…

How to extract word frequency from document-term matrix?

I am doing LDA analysis with Python. And I used the following code to create a document-term matrixcorpus = [dictionary.doc2bow(text) for text in texts].Is there any easy ways to count the word frequen…

Remove only overlapping ticks in subplots grid

I have created a subplots grid without any spaces between the subplots, with shared x,y-axes. I only show the ticks and labels for the outer subplots. The problem is that the tick numbers overlap at th…

how to start a thread when django runserver?

I want to start a thread when django project runserver successfully. where can I put the create-thread-and-start code? Is there any hook for the django runserver?

pandas groupby plot values

I have a pandas dataframe that looks like this:**real I SI weights**0 1 3 0.3 0 2 4 0.20 1 3 0.50 1 5 0.51 2 5 0.3…