首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

android应用程序 nkd jni error: dereferencing pointer to incomplete type解决办法

2012-12-22 
android应用程序 nkd jni error: dereferencing pointer to incomplete type编写android应用程序去操作i2c

android应用程序 nkd jni error: dereferencing pointer to incomplete type
编写android应用程序去操作i2c函数,nkd-build出错: error: dereferencing pointer to incomplete type
以下是我的.c文件


1#include <jni.h>
  2 #include <stdio.h>
  3 #include <string.h>
  5 #include <android/log.h>
  6 #include <linux/i2c.h>
  7 #include <malloc.h>
  8 #include <memory.h>
  9 #include <fcntl.h>
 10 #include <linux/delay.h>
 12 //#include <sys/ioctl.h>
 13
 14 #define  LOG_TAG    "i2c"
 15 #define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__    )
 16 #define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS_    _)
 17
 18 //-------------------
 19 extern struct i2c_client *infer_ldtp_i2c_client;
 20
 21 JNIEXPORT jint JNICALL Java_com_example_ips_1tp_1update_IPS_1tp_1updateActiv    ity_open(JNIEnv *env, jobject obj, jstring file)
 22   {
 23       LOGI("begin to open");
 24       char fileName[64];
 25       const jbyte *str;
 26
 27       str = (*env)->GetStringUTFChars(env, file, NULL);
 28       if (str == NULL) {
 29           LOGI("Can't get file name!");
 30           return -1;
 31       }
 32       sprintf(fileName, "%s", str);
 33     LOGI("will open i2c device node %s", fileName);
 34       (*env)->ReleaseStringUTFChars(env, file, str);
 35       LOGI("out open");
 36 //-------------------
 37         struct i2c_client *client = infer_ldtp_i2c_client;
 38         int ret;
 39         struct i2c_msg msgs[] = {
 40                 {
 41                         .addr   = client->addr, ------------------>这里出错
 42                         .flags  = 0,
 43                         .len    = 1,
 44         //              .buf    = cmdbuf,
 45                 },


 46                  {
 47                         .addr   = client->addr, --------------------->这里出错
 48                         .flags  = 1,
 49                         .len    = 1,
 50                 //      .buf    = cmdbuf,
 51                  },
 52         };
 53         ret = i2c_transfer(client->adapter, smgs, 2);--------------------->这里出错
 54         LOGI("ret = " + ret);
 55 //-------------------
 56       return open(fileName, O_RDWR);
 57   }


[最优解释]
求围观!
有没有像linux下编译模块一样,指定linux源码所在的目录,在jni下编译单个文件,它用到了i2c.h,但i2c.h中又用到了其它的好多函数和结构体.
求解
[其他解释]
以下是我的Android.mk

  1 LOCAL_PATH := $(call my-dir)
  2
  3 include $(CLEAR_VARS)
  4 LOCAL_MODULE := IPS_Update
  5 LOCAL_SRC_FILES := IPS_Update.c
  6 LOCAL_LDLIBS := -llog
  7 include $(BUILD_SHARED_LIBRARY)
  8

[其他解释]
<i2c.h>

struct i2c_client {
unsigned short flags;/* div., see below*/
unsigned short addr;/* chip address - NOTE: 7bit*/
/* addresses are stored in the*/
/* _LOWER_ 7 bits*/
char name[I2C_NAME_SIZE];
struct i2c_adapter *adapter;/* the adapter we sit on*/
struct i2c_driver *driver;/* and our access routines*/
struct device dev;/* the device structure*/
int irq;/* irq issued by device*/
struct list_head detected;
};


[其他解释]
求教各位:
android-ndk-r6目录下的linux/i2c都换成了有i2c_client的,
[其他解释]
该回复于2012-09-15 11:33:54被版主删除
[其他解释]
调用了linux中i2c函数,我该如何编译这个so呢?如何在linux源码中编译
[其他解释]
       up!求围观

热点排行