Friday, 20 November 2009

Moving to Android NDK 1.6 from Android NDK 1.5 ...

I've updated my Android configuration to NDK 1.6, and am using the latest STLPort download.

There were a few things that changed, mainly system paths, as some posters to my blog were kind enough to point-out in earlier posts.

Here are some notes on that process, from the point of view of a cygwin-based setup under Windows. The comments generally apply to Linux/Mac as well, however.

Getting STLPort

I performed the "git" command for STLPort from within the root of the Android NDK folder, in other words from within this folder:


The command to use is this:

git clone git://

This puts the STLPort code in a slightly different place to where it was before, such that the code appears under the ndk-wrappers folder...


... which you'll need to account for when you update the paths!

There were a couple of other things that I found tricky to get right in this transition were as follows.

When you try running, you must do it with "source" otherwise the environment isn't updated properly. In other words, type this:

source ./

If your project is called "fred", then you need to have the following folder:


This should contain just one item, which is the file, with the following (example!) two lines in it:

APP_PROJECT_PATH := /cygdrive/c/DOCUME~1/me/MYDOCU~1/WORKSP~1/fred


Once you've rebuilt STLPort, you need to copy libstlport.a (which seemed to be called libstlport.5.1.a in the previous build system... again, watch out for that!) to a new folder, which you'll need to create in the following location:


The jni folder

You need to have at least two files (your source .cc file, and your file) in the jni folder under your project, which is here in my example:

C:\Documents and Settings\me\My Documents\workspace\fred\jni

In my example, the file contains this data:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

STLPORT_BASE := /cygdrive/c/android-ndk-1.6_r1/ndk-wrappers/stlport

-D__NEW__ \

#Static Libraries:
LOCAL_PREBUILT_LIBS := libs/libstlport.a
LOCAL_STATIC_LIBRARIES := libs/libstlport


Good luck!

That should be enough to get you up-and-running with NDK 1.6!


TheBeast.13 said...

I keep getting this error:

~/Development/android-ndk-1.6_r1/ndk-wrappers/stlport/stlport/stl/_cstdlib.h:140: error: conflicting types for 'abs'
build/platforms/android-4/arch-arm/usr/include/stdlib.h:84: error: previous definition of 'abs' was here

Do you have any idea what that's about?

Pete Cole said...


Using a text editor to loo at line 140 for _cstdlib.h, it appears that the #define block around that line seems to be associated with a Visual Studio version. Which compiler are you using (you need to use gcc from the cygwin command-line)?


TheBeast.13 said...

I'm using make on Mac OS X.

TheBeast.13 said...

I'm sorry, I should have been more clear. The lib builds fine, I had to make some changes to the build scripts, but it works. I get these errors when I try to use STL types in my project.

coolblade said...

I don't believe these are supported by the NDK:
LOCAL_PREBUILT_LIBS := libs/libstlport.a

Are you using the OSP to build?

Pete Cole said...

No, I'm not using OSP. The instructions were certainly valid for 1.5 and 1.6; and I think were pretty much the same for 2.0 and 2.1 where I've also build the STLPort code.

Wouldn't it be nice if Google put STL support directly into the SDK? :)

Hoping this helps,