Question

I want to use some function calls(commands) designed for linux. I can use them by enter the key words in adb(Android CML). Here I found some works some people did.

wget (because it isn't included in most Android device )

Iperf

But after reading their methods or suggestions, I can only understand that I need to use Android NDK and write the correct makefile. I have no idea about building others source code (most of them are C/C++) for linux(only need to use 'make' command mentioned in their README file). The official NDK document is for Java environment to call C lib mainly.

Are there some HOWTO, courses or suggestions for this. Thanks!

I have compiled single cpp file program. I try to compile a alternative version iperf https://github.com/tierney/iperf

It seems to be relative to lib ,some header files, and multiple c files. I failed to compile by enter all c files normally. Is there anything I missed?

Was it helpful?

Solution


yeah you need the NDK, it offers an C/C++ compiler for Android.
In general the steps are all the same:

  • Setting up the NDK (I wrote a small how-to, but it's for Arch-Linux and the fish-shell, Windows how-to)
  • Adjusting your make file (instead of gcc compiler use Android NDK compiler, and so on)
  • Remember that Android uses Bionic C library, so only use functions supported by it
  • Run make, push the program to your device and make it executable

Of course, this is just an overview how it is done. You should try it and then ask specific questions if you run into troubles.

OTHER TIPS

NDK is mostly intended to extend the Java apps, but you can download NDK and create a standalone toolchain from it (see http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html). Now you have a cross-compilation environment which is very similar to standard Linux dev environment.

In addition, for small executables and for testing only, you can also cross-compile and link statically to the libc. This way you don't have to worry about Bionic which could be a loss of time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top