build native code for android 64-bit arm architecture - android

We have a native .so file for 32-bit Android. We need to port it to 64-bit Android code (for Android L). We are not using NDK to build. We use make files and arm-linux-androideabi-g++ with command line options to build our source.
Can someone please let me know how to port our code to 64-bit Android platform?

You'll need to create a new standalone toolchain (same process you used to generate arm-linux-androideabi-g++) for arm64 (requires NDK r10).
http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html

Related

Android studio - Call to function from dll file or lib file

I have a lib and dll files (I can choose which file I want to use)
I want to call to functions that are inside the file.
The code that complied in dll/lib wrote at c
dll files (unless the dll is a dot.net dll and you are in a Xamarin app) are not usable in Android.
Furthermore DLL files typically are compiled for x86 (32bit) or x86_64 (64bit) CPUs. The number of Andorid devices with an x86 CPU is next to zero, for Android you need the library compiled for ARMv7 (32bit) and ARMv8 (64bit). As Android is Linux based you need .so files in stead of .dll files.
To make development easier you should install Android Studio + Android NDK (Native Development Kit). Then you have everything for compiling c code in a way that you can make use of it within an Android app.
Google provides multiple sample projects that show how to use NDK: https://developer.android.com/ndk/samples

Building with Address Sanitizer on Android but with CMake

I am trying to build a .so for android and I want to build with address sanitizer but the only instructions I see are for Android NDK based Makefiles, but I am using the newer endorsed CMake setup. Just adding the flag -fsanitize=address wasn't enough as the clang runtime library was missing.
what is the correct thing to add in my CMakeLists for Android built libraries?
You also need to prepare your device as described in documentation. You have to run asan_device_setup script from NDK. It will put asan .so on the device.

Difference in the 32-bit binaries built using ndk32-r10b and ndk64-r10b

Can anybody explain me what is the difference in 32-bit armeabi binaries compiled using ndk32-r10 build and ndk64-r10 build?
I am having several native libraries in my android project. Initially I was using android ndk-r9d build to compile these binaries for armeabi platform.
Now I have made some changes to one of the library and compiled it using ndk32-r10b build for armeabi.
Everything worked fine.
After this I compiled the same 32-bit binary with ndk64-r10b build for armeabi platform, which got compiled successfully. But at runtime it throws an error that it can not load/find library.
Please note that compilation succedded but it could not load the library at run time.
Can anybody tell me what is the difference in the 32-bit binaries built using ndk32 and ndk64?
Because according to my understanding ndk64 should be able to compile both 32-bit and 64-bit binaries as it is having options for both the platforms.
Is it related to any specific changes made for Android L in the binaries built using ndk64 build, if any?
Thanks for your help in advance.

Build Rsync for 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.

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