Can't include STL header files with Android NDK r5
Asked Answered
T

2

6

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
Tmesis answered 16/12, 2010 at 17:46 Comment(0)
L
5

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.

Larrup answered 16/12, 2010 at 17:52 Comment(4)
That shouldn't make a difference as the error is file not found.Tmesis
@Mark: of course it can. The include paths of C and C++ compilers may be different.Larrup
@Mark: Note: verified: gcc rejects <vector> when compiled as C.Larrup
You're exactly right, tried it this morning when I got in. Thanks very much :)Tmesis
H
4

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.

Headstone answered 16/12, 2010 at 17:56 Comment(1)
Hi, I've read that file, and I forgot to mention originally that I do have APP_STL set in Application.mk.Tmesis

© 2022 - 2024 — McMap. All rights reserved.