Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't include STL header files with Android NDK r5

I've got a very simplistic application:

#include <vector>

void android_main(struct android_app* state)
{

}

When I build it, I get the following error:

test/jni/main.c:14:18: error: vector: No such file or directory

How the hell do I include STL header files? I've found stlport, and I can see the header files exist in it's directory, but how do include them?

Edit: My Application.mk file has the following line:

APP_STL := stlport_static
like image 554
Mark Ingram Avatar asked Dec 16 '10 17:12

Mark Ingram


2 Answers

test/jni/main.c:14:18: error: vector: No such file or directory

You're compiling with a C compiler, probably. Change the extension to *.cpp and check that a C++ compiler is invoked in the tool-chain.

like image 178
Yakov Galka Avatar answered Sep 23 '22 16:09

Yakov Galka


Read the documentation in $NDKROOT/docs. Specifically CPLUSPLUSSUPPORT.html.

The default C++ library supports only a very limited set of features. The c++ library can be changed with the APP_STL variable in your Application.mk.

like image 32
Chris Hopman Avatar answered Sep 20 '22 16:09

Chris Hopman