【发布时间】:2013-09-22 06:33:01
【问题描述】:
我想使用 openssl 的 RSA,所以我需要用 ndk 将 openssl 集成到 Android。我在 https://github.com/aluvalasuman/OpenSSL1.0.1cForAndroid 下载了适用于 Android 的 openssl 源。
ndk-build在源文件夹中生成libcrypto.so和libssl.so,我将它们复制到$(MY_PROJECT)/jni/lib/,然后将它们链接到Android.mk中:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_LIBS := $(LOCAL_PATH)/lib
LOCAL_STATIC_LIBRARIES := libcrypto libssl
LOCAL_LDLIBS := -llog
LOCAL_MODULE := jni
LOCAL_SRC_FILES := jni.c
include $(BUILD_SHARED_LIBRARY)
并像这样测试了openssl:
#include <stdio.h>
#include <string.h>
#include <openssl/rsa.h>
#define nr_bits 2048
int test_openssl()
{
RSA *rsa = RSA_generate_key(nr_bits, 65537, NULL, NULL);
return 0;
}
当我编译它时,它抛出了错误:
....jni/license/license.c:10: error: undefined reference to 'RSA_generate_key'
collect2: ld returned 1 exit status
有谁知道问题出在哪里?如果有人能提供帮助,我将不胜感激。
【问题讨论】: