Is there any info about the future of extending the safe C++ header list in the NDK (or maybe some hints to what might be safe to use) ? Or how soon we can expect the next NDK update? Also will there be any tutorials and documentation comming out for the NDK?
Thanks
If you are interested in using C++ with the Android NDK you should check out the modified NDK by CrystaX. He has rebuilt the Android NDK so that it has full support for C++, including C++ Exceptions, RTTI (Run Time Type Identification) and the Standard C++ Library.
There aren't that many changes, in fact CrystaX offers a link to the complete patch file from his website.
Check it out at http://www.crystax.net/android/ndk-r4.php
i'm not aware of any announcements regarding future plans.
the samples are here:
http://developer.android.com/sdk/ndk/1.6_r1/index.html#samples
and the NDK itself contains documentation in the form of .txt files in the docs/ directory.
Related
I'm having a hard time finding an up-to-date answer to this question. Many existing answers refer to older versions of AS, and are now obsolete.
I want to use a precompiled debug build of a C++ shared library. I also want to be able to step through calls to this library.
I have successfully created a basic app with NDK support and some JNI code. I can step through the JNI code in the debugger.
Two questions:
How do I add the shared library and its headers to the app?
How can I reference the source code of the precompiled library so that it can be accessed in the debugger?
I am not a C++ expert, so please explain in noob terms. Thanks.
So, I have a little C library. I want to make this library available to other devs that develop native C code in android (other libraries, native apps etc).
What's the best way to go? I don't really have much clue yet, trying to figure all this out.
I've read that there are two paths to go with the NDK: using Android.mk and using create-standalone-toolchain -- is this correct? How does each one of these works? Is there a third way without the NDK, and should this be used now that the NDK is available?
**
This may have been asked before, but I understand things have changed since the release of the NDK, as a lot of posts I find seem obsolete.
this question can have a Huge answer, I will try to be as brief as possible.
Using the Android NDK, make a new android project, create a JNI folder, and create an Android.mk file, in it, make two libs, one being your lib, exported as a shared lib and the other, a jniwrapper that will test it. Here is an example of how it was done by a guy for his own lib.
You can make a shared lib by compiling with the standalone toolchain, here is an article on the subject and also take a look at the curl Readme for android, it explains how to compile curl for Android using the standalone toolchain, I believe it's the better way to do it, and also to easier for you since you will use the cross-compiler in a regular fasion...
I am building a multi-platform SDK for real time 3D applications. This SDK is programmed in C++ and works under Windows, Apple's iOs, MacOS, Linux and Android.
The project structure is complex, it consists in 3 native C++ static libraries, linked with some external static libraries in a complete shared library. This is very simple under all the managed OSes, except for Android.
The major problem in Android is bi-directional communication/calls between native code and Java code. I got this solved some time ago using SWIG to wrap the shared library's classes. To achieve that I wrote our my own build scripts (Makefiles) to handle native compilation with the ndk r4, swig code generation, java pre-compilation and jar creation.
Lately we added some callback/listener classes in the C++ layer, that we wanted to be derivable/overloadable in Java, for this we used SWIG's directors feature. But it appears that it needs JNI features (weak global references) that were not in the NDK r4b. So we need to switch to a newer Android NDK (r6b) that has these features. But since our custom build scripts were written for NDK r4b they won't work anymore.
My concern is to have everything built properly through Android's NDK/SDK (eventually through Eclipse) with Android.mk files so we don't have to rewrite everything from scratch each time we switch to a new NDK.
I'd like to know if there is a way to manage such complex project structure with standard Android.mk, ndk-build, ant and eclipse (including the SWIG part). And if so, how ?
Don't hesitate to ask for precisions, I am not sure I am being really clear.
Any help greatly appreciated.
Florent Lagaye.
I've been looking for a similar thing and, although I haven't figured it out yet, there is a good example with building gstreamer on Android.
http://cgit.collabora.com/git/user/derek/androgenizer.git/
It supposedly works with any libtoolized application.
Here is the directions for how to build:
http://gstreamer.freedesktop.org/wiki/GstreamerAndroid_InstallInstructions
What we ended doing is writing specific rules in the Android.mk file to manage swig interface generation.
Remember to add the generated c++ source to the list of source files before including BUILD_STATIC_LIB or BUILD_DYNAMIC_LIB, and to instruct swig to generate the java source in folder accessible by your Android java project.
Are there any libraries available by default in the Android NDK? If not, can I use any c++/c library, as long as I include it myself?
In particular, I need compression, encryption, regex and sqlite. I was thinking of using zlib, crypto++, sqlite(duh!) and boost, but can use anything else if it is already available.
Also, if nothing is available built-in, would you recommend something other then my above choice (I prefer public-domain when possible, or BSD or similar)
SQLite is available on Android via abstracted database access in Java. The .so itself is private. You can of course compile your own SQLite library if you require modifications, but in general you should access it from Java. I have done this for encryption purposes.
zlib is available to the NDK
crypto++ could of course be compiled via the NDK
Boost certainly works on Android/NDK (I'm currently using it heavily)
By default Android NDK delivers some libraries, so called 'stable native APIs' (http://developer.android.com/sdk/ndk/overview.html):
libc (C library) headers
libm (math library) headers
JNI interface headers
libz (Zlib compression) headers
liblog (Android logging) header
OpenGL ES 1.1 and OpenGL ES 2.0 (3D graphics libraries) headers
libjnigraphics (Pixel buffer access) header (for Android 2.2 and above).
A Minimal set of headers for C++ support
OpenSL ES native audio libraries
Android native application APIS
First, I think you need to download the NDK package from here: http://developer.android.com/sdk/ndk/index.html and investigate the documentation from the package. I'm sure you will get the answers to most of your questions.
And quick answer to your questions. Yes there are libraries by default in the Android NDK. For example standard C and C++ libraries.
This is only a partial answer with respect to Crypto++....
Crypto++ has a wiki page with build instructions from the command line at Android (Command Line). The process will create the various libraries and show you how to build cryptest.exe to verify the library on a device. But you will still need to create you wrapper project using Android's build system.
Piotr Morgwai Kotarbiński has a page on building the Crypto++ library with Android's modified build system. See Building Crypto++ with NDK toolchain. I don't believe Piotr's article verifies the library on a device.
Hey guys!
I've been working on c++ application lately which has to be run on Android 2.1 and 2.2.
so I am wondering if I have complete c++ application can I just put it into *.so file and then create android project and just simply load this library using System.loadLibrary(blalba.so);
would it work?
Yes you will have to recompile all the native libraries specifically for Android. Yes, you do need the source code for all 3rd party native libs you plan to use simply because Usually when we compile and link these libraries outside Android they are linked to glibc but unfortunately Android doesn't use glibc due to liscence and performance issues. Android uses a watered down version of glibc called libc. It has matching symbol names to glibc for most of the usual functionalities. But as far as i know the libc doesn't have some functionality related to Strings and it definitely doesnt have some posix support. If your native libraries are using any of the deprecated functionality you will have to find workaround for those by using alternative functionality supported by libc and coding your libs accordingly.
Also, as you righty pointed out you will have to use the NDK to interface Java(Android app/fwk) to native world(C++).
Though this sounds pretty simple in my experience compiling native libraries on Android(Android porting) has traditionally been very time consuming with no guarantee of sucesses.