"We human being, always find a solution, maybe not today, but if you really want to solve a problem, there’s always a way" – Ma Yun @ Stanford, 2013

Use C++ stl classes in android ndk project – eclipse

by Md Imran Hasan Hira

In a android ndk project I need to use vector. After including vector and the declaration compiler says that it doesn’t know the vector class. Here is my code and the error –

Source code

Error

 

 

To resolve this, first ensure that your project is NDK project. If not then right click on the project, select “Android Tools” > “Add native support”.

After that create a file in the jni directory named “Application.mk” (PROJECT_ROOT/jni/Application.mk) and add “APP_STL := strlport_static

Application.mk file

 

Then right click on the project and then select “Project Properties” and the add the stl inclusion path. The path is relative to your ndk installation directory. I used eclipse variable $(NDK_DIR) which I included to my eclipse before.

NDK stl location

 

 

After that clean and build your project. Your code should be working with the stl classes now.

 


Leave a Reply

Your email address will not be published. Required fields are marked *

Theme by Ali Han | Copyright 2025 Md Imran Hasan Hira | Powered by WordPress