Nickey
Nickey

Reputation: 47

Trouble w/ std::string when building C++ code in ndk environment

I'm working on some code cuz I was asked to devlep c++ code about core part of a program. But, it's my first time to use ndk so, I had some troubles and resolved that. However, too difficult problem is coming to me. I had building my c++ code w/ ndk but, it said,

.h:3:20: error: string: No such file or directory .h:5: error: 'std::string' has not been declared

and any other errors about that. Below is my 'Android.mk' file I wrote:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := clibs
LOCAL_SRC_FILES := sqlite3.c
LOCAL_LDLIBS    := -llog
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_DEFAULT_CPP_EXTENSION := cpp
LOCAL_MODULE    := mytweetlib
LOCAL_STATIC_LIBRARIES := clibs
LOCAL_SRC_FILES := Friend.cpp SQLiteDB.cpp Cursor.cpp DB4Friends.cpp ResultParser.cpp MyTweet.cpp Stub.cpp
include $(BUILD_SHARED_LIBRARY) 

I tried to link the .c file(sqlite3.c) Making static library file w/ the other file(to be built to shared library). Is there anyone knows about this? Even if it's just very little clue, plz give me that. (I haven't been resolving this problem)

Upvotes: 3

Views: 4628

Answers (2)

mask
mask

Reputation: 6232

I would like to add further to Piklor answer. Do not confuse with "Android.mk" file with "Application.mk" , in your jni folder. Also your include should include string not string.h

Upvotes: 3

Piklor
Piklor

Reputation: 284

It looks like the NDK isn't being told to use stl port.

Try adding an Application.mk file containing APP_STL. This adds the stlport headers to the include path, and links against the libraries.

APP_STL := stlport_static

Upvotes: 7

Related Questions