未定义的参考函数Android NDK

时间:2014-07-20 09:31:33

标签: c++ c android-ndk

我有Detection.hDetection.cpp

Detection.h
#ifndef _DETECTION_H_
#define _DETECTION_H_
#include "Accessories.h"
#ifdef __cplusplus
     extern "C" {
#endif
int detection(container *ct);
#ifdef __cplusplus
     }
#endif

#endif   

Detection.c
#include "Detection.h"
//Local APIs

//Global API
int detection(container *ct)
{

   return 0;
}

我从detection()致电jni.c作为

#include "jni.h"
#include "Detection.h"
int *pthread_func(void *proc_ctrl);

JNIEXPORT jint Java_api_Camera_detect
  (JNIEnv *env, jclass obj, jint do_processing)
{
    int ret;
    int rc;
    void *status;
    pthread_t proc_thread;
    pthread_attr_t attr;
    /* Initialize and set thread detached attribute */
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);

    rc = pthread_create(&proc_thread, NULL, pthread_func, (void *)do_processing);

    pthread_attr_destroy(&attr);
    pthread_join(proc_thread, &status);
    if (!(int)status){//normal exit
        //pass info to Android UI

        ret = 0;
    }else{//problem
        //pass info to Android UI

    }
    pthread_exit(NULL);
    return ret;
}

int *pthread_func(void *proc_ctrl)
{
   int ctrl = (int)proc_ctrl;
   container *ct;
   while(ctrl){
       ct = calloc(1,sizeof (container));
       if(ct == NULL){
           pthread_exit((void*) 1);//Memory allocation error
       }
       ct->numofppl = 0;
       ct->camera_idx = 0;
       ct->frame = camera_get_snapshot();
       //Do detection
       detection(ct);
       if(ct->frame != NULL)
           free(ct->frame);
       if(ct->locs != NULL)
           free(ct->locs);
       free(ct);
   }

   pthread_exit((void*) 0);
   return 0;
}

我从detection()拨打pthread_func(),我收到了未定义的引用错误。可能有什么不对?

EDIT1:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES :=      \
    test1.c       \
    test2.c           \
    test3.cpp

LOCAL_MODULE:= camera

LOCAL_CFLAGS = -O2 -Wall -Wl,-Bsymbolic -DANDROID -DHAVE_ANDROID

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include

LOCAL_LDFLAGS += -llog -L $(LOCAL_PATH)/libs -camera_wrapper -lusb

LOCAL_MODULE_TAGS := optional

LOCAL_PRELINK_MODULE := false

include $(BUILD_SHARED_LIBRARY)

#########################################################################
# Build libusb_camera_native
include $(CLEAR_VARS)

LOCAL_SRC_FILES :=  \
    com_UsbCamera.c

LOCAL_MODULE:= usb_native

LOCAL_CFLAGS = -O2 -Wall -Wl,-Bsymbolic -DANDROID -DHAVE_ANDROID

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include

LOCAL_LDFLAGS += -llog -L$(LOCAL_PATH)/libs -lusb_camera_wrapper -lusb -L$(LOCAL_PATH)/../libs/armeabi -lusb_camera_simple

LOCAL_MODULE_TAGS := optional

LOCAL_PRELINK_MODULE := false

include $(BUILD_SHARED_LIBRARY)

0 个答案:

没有答案