Build Rsync for Android - android

I have downloaded rsync from http://rsync.samba.org/
anyone knows how to compile the source code to be deployed in an Android Device?

You can compile without the NDK assuming you statically link. This works for me on Ubuntu 13.04 Raring Ringtail.
Install the cross compiler:
sudo apt-get install gcc-arm-linux-gnueabi
Download rsync:
wget http://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gz
tar -zxv -f rsync-3.0.9.tar.gz
cd rsync-3.0.9
Compile with the cross compiler, using static linking:
./configure --host=arm-linux-gnueabi CFLAGS="-static"
make
You'll get some warnings along the lines of Using X in statically linked applications requires at runtime the shared libraries from the glibc version used for linking. But so far, rsync has worked for me.
And finally, install to your phone (assumes you are using SSHDroid):
scp -P 2222 rsync root#$PHONE_IP:/data/data/berserker.android.apps.sshdroid/dropbear

You'll need the Android NDK found here
There are examples included on the web page and download of how to compile C code for Android.
From the NDK Website:
The NDK provides:
A set of tools and build files used to generate native code libraries
from C and C++ sources
A way to embed the corresponding native
libraries into an application package file (.apk) that can be deployed
on Android devices A set of native system headers and libraries that
will be supported in all future versions of the Android platform,
starting from Android 1.5. Applications that use native activities
must be run on Android 2.3 or later. Documentation, samples, and
tutorials
I did also find this if it's close to what you want to achieve.

Related

How do I include externally-built C/C++ libraries (e.g. OpenSSL) in Android Studio

I want to develop a C++ Android app using Android Studio.
If I need to include an external library, I may need to build it separately. For example, I may need OpenSSL which has Android NDK build instructions here. The instructions in that link are of this kind:
sudo -E make install CC=$ANDROID_TOOLCHAIN/arm-linux-androideabi-gcc RANLIB=$ANDROID_TOOLCHAIN/arm-linux-androideabi-ranlib
arm-linux-androideabi-gcc -I /usr/local/ssl/include my_prog.c -o my_prog.exe -L /usr/local/ssl/lib -lssl -lcrypto
If I'm reading this right, the first line cross-compiles the library and the second line builds my_prog, linking to said library. But if I am using Android Studio to build the app, how do I integrate that with the library produced via the make install line?

Cross-compile gmp in gcc from Android NDK, failed to execute ./gen-fac_ui

I'm building gcc for Android on CentOS using the cross-compile toolchain generated by running the make-standalone-toolchain.sh script in the Android NDK, and the gcc source files from the downloaded Android NDK toolchain sources. The GMP sources were obtained by running the download_prerequisites script located in the gcc/contrib folder.
I've specified --build=x86_64-linux and --host=arm-linux-eabi, cross compile tools are set in the env variables, and specified when running configure. I've run ../gcc-4.7/configure, then make -d. Make fails when building gmp with /bin/sh. ./gen-fac_ui. Cannot execute binary.
The specific command is: ./gen-fac_ui $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpz/fac_ui.h || (rm -f mpz/fac_ui.h; exit 1)
I'm guessing the execution fails because I'm using cross-compile tools and the gen-fac_ui binary won't run on CentOS. My question is: is there another way to generate mpz/fac_ui.h as a work around?
I've also tried running make -d -i, which finishes successfully but seems to skip building key files...like gcc or g++
Short Answer:
I needed the native (i.e for CentOS) GCC tools to build and run gen-fac_ui.
Long Answer:
This is my post at the OSDev forum, where I basically asked the same question and got an answer. It also contains my error (and correction) of not having glibc-devel installed for the
native GCC toolchain.
In addition, since the base version of GCC for my build system was 4.4.7 and I was trying to cross-native build 4.7, I had to get the developer toolset, which can be installed via yum. Information on the toolset is here and easy install instructions are here
FWIW, I'm still not entirely sure how I was supposed to determine that gen-fac_ui needed to be made by a gcc native to the build machine...other than there was no other way I could find to generate fac_ui.h and other headers.

Cygwin for Android-NDK programming

I read about the requirements of NDK programming on Windows which said we require Cygwin.Read about Cygwin which said we require it coz it is a way to make Windows support some linux functionality.But my question is in which stage of programming(Where Exactly) Cygwin will be required and why? Addidtional info about this topic is most welcomed
Android NDK starting with revision 7 doesn't require Cygwin. See here: http://developer.android.com/sdk/ndk/index.html
You can now build your NDK source files on Windows without Cygwin by calling the ndk-build.cmd script from the command line from your project path. The script takes exactly the same arguments as the original ndk-build script. The Windows NDK package comes with its own prebuilt binaries for GNU Make, Awk and other tools required by the build. You should not need to install anything else to get a working build system.
It mentions you can not use ndk-gdb script without Cygwin. While that is true, you can actually use gdb executable directly without Cygwin, only then you'll need to set it up properly manually.
At least NDK-r8b, if you want to build your .so, you don't need Cygwin.
However, if you want to use ndk-gdb to debug your native code,you have to use Cygwin.
And, in my experiment, if you ndk-gdb your native under Cygwin to debug native code which is built from windows cmd, ndk-gdb seems cannot recognize the debug info. So, for debug purpose, I build native Cygwin.
Make command to execute Android.mk file.
Android.mk file consists of list of c/c++ files to be compiled and also the library name(.so).
(from NDK-r8e NDK-GDB document) At the moment 'ndk-gdb' requires a Unix shell to run. This means that Cygwin is required to run it on Windows. We hope to get rid of this limitation in a future NDK release.

Compile native c binaries for Android - Eg: dosfsck

I am trying to compile the binary dosfsck and mkdosfs for Android, using Linux and Android NDK and SDK. I've setup NDK and SDK properly, the path to the NDK gcc is in my path. I've also downloaded the correct SDK for my device (HTC Desire).
I first tried compiling the file with a simple make:
make
CROSS_COMPILE=/home/droidzone/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
I need to be able to run the binary from my device. As it is, the app compiles and runs on Ubuntu, but not my device. I get the error message from sh: Cannot run binary
Could someone please explain how I can link libraries, where I should get them from (within the SDK) and what changes if any to make to the Makefile, and the final syntax to compile this properly for Android
I found this was easiest to do using the agcc script script which you can use by exporting CC=agcc. Lots of projects will not properly support CROSS_COMPILE as you have tried. The agcc script is oriented around using the Android build tree files so I modified it to use the NDK tools. With this you should be able to build most things using make CC=agcc or CC=agcc ./configure

Android and cross-compiling

I have a Linux library that needs to be compiled under Android. I understand that should be used to build this program: / home/user/android-ndk/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-gcc and then compile a ndk-build . I think right? Assembly via the utility should work correctly?
You need to install the Native Development Kit (NDK) and read through the documentation in the NDK about the build process. The NDK basic info is at http://developer.android.com/sdk/ndk/index.html, and you'll need to install an appropriate version of Cygwin (if you're using Windows).
It comes with a prebuilt compiler, so you shouldn't have to rebuild that.

Categories

Resources