为平台2.1构建Android-openssl库

Sus*_*hil 6 java-native-interface android openssl shared-libraries android-ndk

我使用https://github.com/eighthave/openssl-android给出的open-ssl源 来构建一个可以在android项目中使用的库.

根据README.txt中给出的说明,我可以为Android平台版本2.2(级别-8)编译它

但我的应用程序要求它与2.1(级别-7)兼容.

我尝试使用default.properties文件执行以下选项(https://github.com/eighthave/openssl-android/blob/master/default.properties)

1)设置target = android-7

2)设置target = android-5

但是当我使用命令ndk-build编译它时,它会产生以下错误

    Compile thumb  : crypto <= dsa_vrf.c
    Compile thumb  : crypto <= dso_dl.c
    Compile thumb  : crypto <= dso_dlfcn.c
    /Crypto/openssl-android/crypto/dso/dso_dlfcn.c: In function 'dlfcn_pathbyaddr':
    /Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: 'Dl_info' undeclared (first    use in this function)
    /Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: (Each undeclared identifier   is reported only once
    /Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: for each function it appears in.)
    /Crypto/openssl-android/crypto/dso/dso_dlfcn.c:445: error: expected ';' before 'dli'
    /Crypto/openssl-android/crypto/dso/dso_dlfcn.c:455: error: 'dli' undeclared (first use in this function)
    make: *** [obj/local/armeabi/objs/crypto/dso/dso_dlfcn.o] Error 1
Run Code Online (Sandbox Code Playgroud)

根据错误消息 - 未定义Dl_info.但是如果我们去文件dso_dlfcn.c,则已经提供了结构的定义.(https://github.com/eighthave/openssl-android/blob/master/crypto/dso/dso_dlfcn.c)

并且此代码在默认属性文件中为target = android-8编译,但不适用于android-7或android-5.

请求您帮我解决此错误.并让我知道为了编译它为Android 2.1平台需要做的所有更改.

提前致谢.

Yur*_*ury 6

尝试将以下代码包含在dso_dlfcn.c中:

typedef struct {
const char *dli_fname;  /* Pathname of shared object that
                           contains address */
void       *dli_fbase;  /* Address at which shared object
                           is loaded */
const char *dli_sname;  /* Name of nearest symbol with address
                           lower than addr */
void       *dli_saddr;  /* Exact address of symbol named
                           in dli_sname */
} Dl_info;
int dladdr(const void *addr, Dl_info *info) { return 0; }
Run Code Online (Sandbox Code Playgroud)

之前:

#ifdef __linux
# ifndef _GNU_SOURCE
#  define _GNU_SOURCE   /* make sure dladdr is declared */
# endif
#endif
Run Code Online (Sandbox Code Playgroud)

在我的情况下,建立了库.