LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := jni_vrpn_button
LOCAL_SRC_FILES := jni_vrpn_button.cpp
include $(BUILD_SHARED_LIBRARY)
jni_vrpn_button.h:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class jni_VrpnButton */
#ifndef _Included_jni_VrpnButton
#define _Included_jni_VrpnButton
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: jni_VrpnButton
* Method: vrpn_Button_initialize
* Signature: (Ljava/lang/String;J)J
*/
JNIEXPORT jlong JNICALL Java_jni_VrpnButton_vrpn_1Button_1initialize
(JNIEnv *, jobject, jstring, jlong);
/*
* Class: jni_VrpnButton
* Method: vrpn_button_mainloop
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_jni_VrpnButton_vrpn_1button_1mainloop
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
}
#endif
#endif
jni_vrpn_button.cpp:
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <jni_vrpn_button.h>
#include <vrpn_Button.h>
#include <vrpn_Connection.h>
/*
* Class: jni_VrpnButton
* Method: vrpn_Button_initialize
* Signature: (Ljava/lang/String;J)J
*/
JNIEXPORT jlong JNICALL Java_jni_VrpnButton_vrpn_1Button_1initialize
(JNIEnv * env, jobject, jstring n, jlong conn)
{
const char* name = strdup(env->GetStringUTFChars(n, 0));
vrpn_Button_Example_Server * serv = new vrpn_Button_Example_Server(name, (vrpn_Connection *) conn, 1, 1.0);
return (long) serv;
}
/*
* Class: jni_VrpnButton
* Method: vrpn_button_mainloop
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_jni_VrpnButton_vrpn_1button_1mainloop
(JNIEnv *, jobject, jlong ptr)
{
((vrpn_Button_Example_Server *) ptr)->mainloop();
}
有什么想法?
编辑:忘记发布错误信息:
$ $CRYSTAX/ndk-build SharedLibrary : libjni_vrpn_button.so /cygdrive/c/Development/android-ndk-r4-windows-crystax-4/android-ndk-r4-crystax/sources/string/obj/l ocal/armeabi/objs/jni_vrpn_button/jni_vrpn_button.o: 在函数中
Java_jni_VrpnButton_vrpn_1Button_1 initialize': /cygdrive/c/Development/android-ndk-r4-windows-crystax-4/android-ndk-r4-crystax/sources/string/jni/j ni_vrpn_button.cpp:18: 未定义的引用 到
vrpn_Button_Example_Server::vrpn_Button_Example_Serve r(char const*, vrpn_Connection*, int, double)' collect2: ld 返回 1 退出 状态 make: *** [/cygdrive/c/Development/android-ndk-r4-windows-crystax-4/android-ndk-r4-crystax/sources/s tring/obj/local/armeabi/libjni_vrpn_button.so] 错误 1