I found an article by Vikram Aggarwal that talks about linking Assembly code into Android's NDK, which even has some example code which shows how to connect the C++ code with Assembly. ( see http://www.eggwall.com/2011/09/android-arm-assembly-calling-assembly.html )
My problem is that I want to use the same function but instead of calling it from JNI stub class, I want to call my Assembly function from my private class.
But on compilation, I get the error:
error: 'armFunction' was not declared in this scope
Has anyone tried this or have any idea how to resolve this ?
Edit:
Makefile:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := quake3
# I want ARM, not thumb.
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES := \
multiple.s \
macros.h \
math/Vector2.cpp\
math/Vector3.cpp\
math/plane.cpp\
engine/frustum.cpp\
engine/BoundingVolume.cpp\
engine/camera.cpp\
camera-proxy.cpp\
LOCAL_CFLAGS := -DANDROID_NDK \
-DDISABLE_IMPORTGL \
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog
#LOCAL_LDLIBS := -llog -lGLESv2
APP_STL := gnustl_static
APP_CPPFLAGS := -S -frtti -fexceptions
APP_ABI := armeabi armeabi-v7a
include $(BUILD_SHARED_LIBRARY)
Function call in cpp file:
void
Java_surreal_quake3_engine_Camera9_nativeGetDirection(JNIEnv* env, jobject thiz)
{
//Camera* camera = (Camera*) env->GetIntField(thiz, pointerID);
// get the _Z as the Vector3 java object
jfieldID vector_fID = env->GetFieldID(cls, "_Z", "Lsurreal/libs/math/Vector3;");
jobject vector_obj = env->GetObjectField(thiz, vector_fID);
// call the setter methods on the _vecEye
//jclass vectorClass = env->FindClass("surreal/libs/math/Vector3");
jmethodID vector3_set = env->GetMethodID(vector3Class, "set"/*method-name*/, "(FFF)V" /*method-signature*/);
env->CallVoidMethod(vector_obj, vector3_set, camera->getZ().x, camera->getZ().y, camera->getZ().z);
int result = armFunction();
}