Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Android-openssl library for platform 2.1

I am using open-ssl source given at https://github.com/eighthave/openssl-android to build a library which can be used in android project.

As per instructions given at README.txt, I am able to compile it for the the Android platform version 2.2 (level -8)

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

I tried following options with the 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 using command ndk-build, it gives 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

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

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

Request you to help me to resolve this error. and let me know what all changes needs to be done in order to compile it for android 2.1 platform.

Thanks in advance.

like image 836
Sushil Avatar asked Dec 04 '11 20:12

Sushil


1 Answers

Try to include the following piece of code into 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 is built.

like image 65
Yury Avatar answered Oct 19 '22 08:10

Yury