-2

android项目:我有c。文件 :

      /* DO NOT EDIT THIS FILE - it is machine generated */
     #include <com_jp_algi_Corelib.h>
           /* Header for class com_jp_algi_Corelib */
       #ifdef __cplusplus
       #define EXTCFUNC extern "C"
          #elseif
        #define EXTCFUNC extern
        #endif




        JNIEXPORT jfloatArray JNICALL Java_com_jp_algi_Corelib_vector
        (JNIEnv * env, jobject clazz, jfloatArray input){

      jfloatArray result;




              }

                jfloat* flt1 = env->GetFloatArrayElements(input,0)

;insiperd by : 堆栈流中的 Eiegen android。

并且有一些错误:

C:/AA/FileBroswerActivity/jni/com_jp_algi_Corelib.c:23: error: 'env' undeclared here (not in a function)
C:/AA/FileBroswerActivity/jni/com_jp_algi_Corelib.c:23: error: 'input' undeclared here (not in a function)
/cygdrive/c/android-ndk-r5c/build/core/build-binary.mk:217: recipe for target `/cygdrive/c/AA/FileBroswerActivity/obj/local/armeabi/objs/com_jp_algi_Corelib/com_jp_algi_Corelib.o' failed
make: *** [/cygdrive/c/AA/FileBroswerActivity/obj/local/armeabi/objs/com_jp_algi_Corelib/com_jp_algi_Corelib.o] Error 1

16:52:03 构建完成(耗时 672 毫秒)

4

1 回答 1

0

你的帖子真的不清楚,但你的文件应该是这样的

  • .h 文件:

    #include <jni.h>
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    jfloatArray JNICALL Java_com_jp_algi_Corelib_vector(JNIEnv * env, jobject clazz, jfloatArray input);
    
    #ifdef __cplusplus
    }
    #endif
    
  • .cpp 文件:

    #include "yourheader.h"
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    jfloatArray JNICALL Java_com_jp_algi_Corelib_vector(JNIEnv * env, jobject clazz, jfloatArray input)
    {
      jfloat* flt1 = env->GetFloatArrayElements(input,0);
    }
    
    #ifdef __cplusplus
    }
    #endif
    

编辑(编辑后):

jfloat* flt1 = env->GetFloatArrayElements(input,0);

在函数体之外

于 2012-12-28T16:04:26.880 回答