2011-12-04 43 views
6

我使用的是open-ssl源码,在https://github.com/eighthave/openssl-android 构建了一个可以在android项目中使用的库。为平台2.1构建Android-openssl库

按在README.txt中给出的指示,我能够编译它的Android平台版本2.2(级-8)

但我的应用程序需要它是2.1(级-7)兼容。

我试图在与default.properties文件(https://github.com/eighthave/openssl-android/blob/master/default.properties

1)设定的目标=机器人-7

2)设定的目标选项=机器人-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 

根据错误消息 - 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平台而需要做的所有更改。

在此先感谢。

+0

你也有[OpenSSL和安卓(https://开头wiki.openssl.org/index.php/Android)。 – jww

回答

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; } 

前:

#ifdef __linux 
# ifndef _GNU_SOURCE 
# define _GNU_SOURCE /* make sure dladdr is declared */ 
# endif 
#endif 

后,在我的情况下,库建成。

+0

谢谢,图书馆建立成功。 – Sushil

+0

不客气!祝你好运! – Yury

+0

这个问题依然存在.. !!但@Yuri建议的解决方法救了我..谢谢:) –

0

尝试使用最新的NDK版本进行安装并适当更新Application.mk文件。

LOCAL_PATH := $(call my-dir) 
APP_PLATFORM := android-19 
NDK_TOOLCHAIN_VERSION := clang 
APP_ABI := armeabi-v7a 
APP_STL := gnustl_static 
APP_CPPFLAGS += -frtti 
APP_CPPFLAGS += -fexceptions 
APP_CPPFLAGS += -DANDROID 
APP_PROJECT_PATH := $(shell pwd) 
APP_BUILD_SCRIPT := $(LOCAL_PATH)/../Android.mk 

上述2个问题将得到解决。

0

我有@尤里的解决方案的一个问题,并不得不改进它。我的APP_ABIApplication.mk中设置为all。在我的情况下,这意味着armeabiarmeabi-v7a之间我也建设x86mips。我也有android-9 target安装在android sdk中用于其他项目。 x86mips由ndk支持,从android-9开始。正如文档中所写,当ndk-build将开始构建这些目标时,它将自动切换到android-9目标。什么? - 是的,它将无法编译:-)。这里是我的解决方案:

  1. 在crypto/Android.mk找到行local_c_flags := -DNO_WINDOWS_BRAINDEATH。行后写这个http://pastebin.com/7euUVD7A
  2. 尤里的代码必须被插入到if definedhttp://pastebin.com/V58gTSBU
  3. 顺便说一句,我插尤里的块#include <openssl/dso.h>之后而不是之前#ifdef __linux