'Cross-Compiling Library for Android with OpenSSL Dependencies

I'm working on a project, where I have a lot of C code that is supposed to run in Android. My code depends on three libraries: AMCL, OpenSSL, and IBMTSS.

I was able to compile AMCL and OpenSSL to Android x86_64, and it seems to work fine. The problem, however, is IBMTSS. The library needs to be linked with OpenSSL as well. If I simply just build it, it will link with my computers OpenSSL in /usr/local/lib and build a dynamic library. However, this is of course an issue in Android, as the library it is linked with doesn't exist in my lib-folder (and if I put it there, it's rejected for having the wrong architecture.

So I made sure to specify that it should be linked with the android architecture version of OpenSSL I compiled.

./configure --prefix=$(pwd)/build --host=x86_64-linux-android --disable-hwtpm CPPFLAGS="-I/home/benlar/Projects/OpenSSL/openssl_android/inc/x86_64" LDFLAGS="-L/home/benlar/Projects/AndroidSSL/openssl-OpenSSL_1_1_1n"

Now it wont link, with the following error.

/usr/bin/ld: warning: libdl.so, needed by /usr/local/lib/libcrypto.so.1.1, not found (try using -rpath or -rpath-link)                                                                                                                                      
/usr/bin/ld: warning: libc.so, needed by /usr/local/lib/libcrypto.so.1.1, not found (try using -rpath or -rpath-link)                                                                                                                                       
/usr/bin/ld: /usr/local/lib/libcrypto.so.1.1: undefined reference to `strstr@LIBC'                                                                                                                                                                          
/usr/bin/ld: /usr/local/lib/libcrypto.so.1.1: undefined reference to `ftell@LIBC'                                                                                                                                                                           
/usr/bin/ld: /usr/local/lib/libcrypto.so.1.1: undefined reference to `gethostbyname@LIBC'                                                                                                                                                                   
/usr/bin/ld: /usr/local/lib/libcrypto.so.1.1: undefined reference to `sendto@LIBC'

I thought it might be because I said where to look for libraries, so I simply put the Android compiled openSSL in /usr/local/lib.

I guess it's because the android version of OpenSSL now depends on another library, which does not exist for this architecture. Am I forced to recompile the whole dependency chain, or is there something I'm missing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source