Cooper: Java Native Interface question

Hello, I was trying to call c++ function in my Oxygene android app.

Attached is my project.
com.example.rar (187.8 KB)

I created a folder called jni under the project folder.

Then I created a hello-jni.cpp in the jni folder, and its content:
// I found “#include <string.h> #include <jni.h> no showing correctly in the BBS, please open my project jni folder to see it”

#include <string.h>
#include <jni.h>
extern “C” {
JNIEXPORT jstring JNICALL
Java_com_example_Hellojnicpp_stringFromJNI
(JNIEnv *env, jobject obj)
{
return env->NewStringUTF(“Hello from C++ over JNI!”);
}
}

And also created a Android.mk file in the jni folder, and its contents:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := hello-jni

LOCAL_SRC_FILES := hello-jni.cpp

include $(BUILD_SHARED_LIBRARY)

Later I tried to complied the cpp file to generate the file, using the following command:

cd D:\com.example\com.example\jni

D:\android-ndk-r9c\ndk-bulid.cmd

And I got the following error:

I don’t understand the error prompt and not sure where is the problem come from.

Please help me, thanks!

Hi,

hello-jni.cpp contains some garbage symbols.

Thanks for the information, I tried to complied the open source soundtouch library, and it’s OK. I will check where was wrong.