0
當我在eclipse中構建我的Android ndk項目我得到以下錯誤引用使用std :: string作爲參數的函數調用,如果我改變,我會得到一個類似的錯誤const char * arg。我怎樣才能擺脫這種情況,我android.mk連接下面的錯誤:NDK構建未定義的參考...在方法調用
/Applications/adt-bundle-mac-x86_64/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/JsonPoco/JsonPoco.o: in function jsonParse:jni/JsonPoco.cpp:23: error: undefined reference to 'StoreRefListComplexType::StoreRefListComplexType(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
Android.mk
LOCAL_PATH := $(call my-dir)
ROOT_PATH := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PATH = $(ROOT_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_ARM_MODE := arm
LOCAL_MODULE := JsonPoco # Your own library.
LOCAL_SRC_FILES := JsonPoco.cpp # Your own library source.
LOCAL_CFLAGS := -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY
LOCAL_CPPFLAGS := -frtti -fexceptions
LOCAL_STATIC_LIBRARIES := PocoFoundation \
PocoJSON
include $(BUILD_SHARED_LIBRARY)
而且我Application.mk
#Application.mk
APP_STL := gnustl_static
方法調用看起來像這樣,其中test是std :: string:
void jsonParse(JNIEnv* aEnv, jobject aObj){
std::string test= "jsondata...";
ComplexType* ref = new ComplexType(test);
}
我已經採用的方法表中定義的我的jsonParse方法可達通過JNI:
static JNINativeMethod methodTable[] = {
{"json_parse", "()V", (void *) jsonParse}};
和recieving方法/構造:
ComplexType::ComplexType(std::string jsonstring);
沒有源代碼,我們不能幫你。 – Overv 2013-03-22 12:16:11
添加了相關的代碼片段。 – 2013-03-22 13:10:52