2011-12-04 7 views
6

안드로이드 프로젝트에서 사용할 수있는 라이브러리를 빌드하려면 https://github.com/eighthave/openssl-android 에 주어진 오픈 소스를 사용하고 있습니다. 플랫폼 2.1 용 Android-openssl 라이브러리 빌드

README.txt가에 주어진 지침에 따라, 나는 (레벨 -8)

하여 안드로이드 플랫폼 버전 2.2을 컴파일 할 수 있어요하지만 내 응용 프로그램은 2.1 (수준 -7) 호환 가능해야합니다.

I 시도 default.properties 파일 (https://github.com/eighthave/openssl-android/blob/master/default.properties)

1) 설정된 목표 = 로이드 -7-

2) 설정된 타겟 옵션 다음 = 로이드 -5-

을하지만 컴파일 때 Dl_info가 정의되지 않은 메시지 - 명령 NDK 빌드를 사용하여, 그것은 오류를 오류 사항에 따라

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 

에 따라 제공합니다. 그러나 dso_dlfcn.c 파일을 열면 구조체에 대한 정의가 이미 제공됩니다. (https://github.com/eighthave/openssl-android/blob/master/crypto/dso/dso_dlfcn.c)

이 코드는 기본 속성 파일에서는 target = android-8로 컴파일되지만 android-7 또는 android-5에서는 컴파일되지 않습니다.

이 오류를 해결하는 데 도움을 요청하십시오. 안드로이드 2.1 플랫폼 용으로 컴파일하기 위해 모든 변경 사항을 수행해야한다는 사실을 알려주십시오.

미리 감사드립니다.

+0

하기 전에 당신은 또한 [OpenSSL을 안드로이드] (HTTPS가 없습니다 : // wiki.openssl.org/index.php/Android)를 OpenSSL 위키에 추가하십시오. – 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에 의해 제안 된 해결 방법은 나를 구해 줬습니다 .. Thanks :) –

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.mkall으로 설정됩니다. 내 경우에는 armeabiarmeabi-v7a 사이에 x86mips도 있습니다. 나는 android-9 타겟을 다른 프로젝트에서 사용하기 위해 안드로이드 SDK에 설치했습니다. x86mipsandroid-9부터 ndk에서 지원됩니다. 문서에 쓰여 있듯이 ndk-build이 타겟을 빌드하기 시작하면 자동으로 android-9 대상으로 전환됩니다. 그리고 뭐? - 예, 컴파일에 실패합니다 :-). 여기 내 해결책은 다음과 같습니다.

  1. crypto/Android.mk에서 local_c_flags := -DNO_WINDOWS_BRAINDEATH을 찾으십시오. 줄을 쓴 후 http://pastebin.com/7euUVD7A.
  2. 유리의 코드가 if defined에 삽입되어야한다 : 그건 그렇고 http://pastebin.com/V58gTSBU
  3. , 나는 #include <openssl/dso.h> 후 유리의 블록을 삽입했지만 #ifdef __linux
관련 문제