当前位置: 代码迷 >> Android >> android NDK开发,碰到 undefined reference to
  详细解决方案

android NDK开发,碰到 undefined reference to

热度:57   发布时间:2016-04-28 08:00:20.0
android NDK开发,遇到 undefined reference to
我现在有一个android 的工程,有一个des.h头文件和des.cpp、NZEncryption.c两个文件,一些函数在des.h头文件中声明,在des.cpp中实现。然后在NZEncryption.c中使用,

工程目录结构


在NZEncryption.c中声明的头文件
#include <string.h>
#include <jni.h>
#include "des.h"


然后在Android.mk中写的如下:
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog

LOCAL_MODULE    := NewZone01
LOCAL_SRC_FILES := NZEncryption.c\
                   des.cpp

include $(BUILD_SHARED_LIBRARY)


但用Cygwin生成.so文件时,提示:undefined reference to "des_encrypt"
当des_encrypt已在des.h中声明,在des.cpp中实现
不知道怎么回事,该如何在能正确的生成


------解决方案--------------------
C调用CPP里面定义的函数,需要加上内什么
extern "C" {
   ...
}
  相关解决方案