Create Android-openssl library for platform 2.1

I am using open-ssl source specified in https://github.com/eighthave/openssl-android to create a library that can be used in an android project.

According to the instructions given in README.txt, I can compile it for Android platform 2.2 version (level -8)

But my application requires it to be compatible with 2.1 (level -7).

I tried the following options with default.properties file ( https://github.com/eighthave/openssl-android/blob/master/default.properties )

1) set target = android-7

2) set target = android-5

But when I compile it with the ndk-build command, it gives the following error

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 

According to the error message - Dl_info is not defined. but if we go to the dso_dlfcn.c file, a structure definition is already provided. ( https://github.com/eighthave/openssl-android/blob/master/crypto/dso/dso_dlfcn.c )

And this code is compiled for target = android-8 in the default properties file, but not for android-7 or android-5.

Ask you to help me fix this error. and let me know what all the changes need to be done in order to compile it for the Android platform.

Thanks in advance.

+6
source share
3 answers

Try including the following code snippet in 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; } 

Before:

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

After that, in my case, the library will be built.

+6
source

Try installing the latest version of NDK and update the Application.mk file accordingly.

 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 

The above 2 problems will be resolved.

0
source

I had one problem with @Yuri's solution, and I had to improve it. My APP_ABI set to all in Application.mk . In my case, this meant that among armeabi and armeabi-v7a I also create for x86 and mips . I also have android-9 target installed in android sdk for use in other projects. x86 and mips supported by ndk starting from android-9 . As written in the docs, when ndk-build starts building these goals, it will automatically switch to android-9 . So what? - Yes, this will not compile :-). Here is my solution:

  • In crypto / Android.mk find the line local_c_flags := -DNO_WINDOWS_BRAINDEATH . After the line write http://pastebin.com/7euUVD7A .
  • Yuri's code should be inserted in if defined : http://pastebin.com/V58gTSBU
  • By the way, I inserted the Yury block after #include <openssl/dso.h> , but not earlier than #ifdef __linux
0
source

Source: https://habr.com/ru/post/903056/


All Articles