Sqlcipher binary is getting linked with shared libcrypro library


I cross compiled sqlcipher for ARM 32 Ubuntu with the toolchain arm-poky-linux-gnueabi-gcc . I have also cross compiled openssl as sqlcipher must be linked against any one of the crypto libraries. When I do this with latest version of sqlcipher i.e; v4.4.3 then everything works fine.
Note : I have generated sqlcipher application binary by linking against static library libsqlcipher.a and libcrypto.a.
When I link my custom applications with libsqlcipher.a and do the operations on sqlite3 db then db operations become extremely slow. I tried making singleton db handle and giving PRAGMA cipher_memory_security = OFF; but none of them made a significant improvement.

After a bit of research I found that the version v3.4.2 is faster compared to newer version. So I cross compiled the sqlcipher version v3.4.2
Problem : The sqlcipher application binary tries to link with both static and shared library of openssl. When I copy sqlcipher application binary on to the ARM device and run it then it tries to look for libcrypto.so which does not happen in case of newer version of sqlcipher. I found this link and followed the steps but no success. Also, the size of the generated 3.4.2 binary is very less compared to size of the 4.4.3 binary which surely indicates that it did not get linked with static library of openssl.
Compilation procedure:
./configure --target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --prefix=/custom_path/sqlcipher/out --with-crypto-lib=none --disable-tcl --disable-shared --enable-static=yes --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_ENABLE_COLUMN_METADATA -DSQLCIPHER_CRYPTO_OPENSSL -I/path_to_the_cross_compiled_openssl/include/openssl -fPIC" CXXFLAGS="-fPIC" LDFLAGS="/path_to_the_cross_compiled_openssl/lib/libcrypto.a"

When I do make I will get the below errors
**./.libs/libsqlcipher.a(sqlite3.o): In function HMAC_CTX_new': sqlite3.c:(.text+0x5674): undefined reference to CRYPTO_malloc’
sqlite3.c:(.text+0x568c): undefined reference to HMAC_CTX_init' ./.libs/libsqlcipher.a(sqlite3.o): In function HMAC_CTX_free’:
sqlite3.c:(.text+0x56c4): undefined reference to HMAC_CTX_cleanup' sqlite3.c:(.text+0x56cc): undefined reference to CRYPTO_free’
./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_add_random': sqlite3.c:(.text+0x5714): undefined reference to RAND_add’
./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_activate': sqlite3.c:(.text+0x5794): undefined reference to EVP_get_cipherbyname’
sqlite3.c:(.text+0x57dc): undefined reference to OPENSSL_add_all_algorithms_noconf' ./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_deactivate’:
sqlite3.c:(.text+0x58d8): undefined reference to EVP_cleanup' ./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_random’:
sqlite3.c:(.text+0x59e8): undefined reference to RAND_bytes' ./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_hmac’:
sqlite3.c:(.text+0x5a70): undefined reference to EVP_sha1' sqlite3.c:(.text+0x5a90): undefined reference to HMAC_Init_ex’
sqlite3.c:(.text+0x5aa4): undefined reference to HMAC_Update' sqlite3.c:(.text+0x5ac4): undefined reference to HMAC_Update’
sqlite3.c:(.text+0x5ad8): undefined reference to HMAC_Final' ./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_kdf’:
sqlite3.c:(.text+0x5b38): undefined reference to PKCS5_PBKDF2_HMAC_SHA1' ./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_cipher’:
sqlite3.c:(.text+0x5b68): undefined reference to EVP_CIPHER_CTX_new' sqlite3.c:(.text+0x5ba8): undefined reference to EVP_CipherInit_ex’
sqlite3.c:(.text+0x5bb4): undefined reference to EVP_CIPHER_CTX_set_padding' sqlite3.c:(.text+0x5bd8): undefined reference to EVP_CipherInit_ex’
sqlite3.c:(.text+0x5bf4): undefined reference to EVP_CipherUpdate' sqlite3.c:(.text+0x5c24): undefined reference to EVP_CipherFinal_ex’
sqlite3.c:(.text+0x5c3c): undefined reference to EVP_CIPHER_CTX_free' ./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_set_cipher’:
sqlite3.c:(.text+0x5c70): undefined reference to EVP_get_cipherbyname' ./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_get_cipher’:
sqlite3.c:(.text+0x5ccc): undefined reference to EVP_CIPHER_nid' sqlite3.c:(.text+0x5cd8): undefined reference to OBJ_nid2sn’
./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_get_key_sz': sqlite3.c:(.text+0x5d08): undefined reference to EVP_CIPHER_key_length’
./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_get_iv_sz': sqlite3.c:(.text+0x5d38): undefined reference to EVP_CIPHER_iv_length’
./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_get_block_sz': sqlite3.c:(.text+0x5d68): undefined reference to EVP_CIPHER_block_size’
./.libs/libsqlcipher.a(sqlite3.o): In function sqlcipher_openssl_get_hmac_sz': sqlite3.c:(.text+0x5d8c): undefined reference to EVP_sha1’
sqlite3.c:(.text+0x5d98): undefined reference to `EVP_MD_size’

I know its not able to get the reference from libcrypto. When I remove the option –with-crypto-lib=none in configure it will work but produces a sqlcipher application binary which is linked against both static and shared libcrypto (I dont have cross-compiled libcrypto.so!! but still it links!!!). When I include –with-crypto-lib=none and also -DSQLCIPHER_CRYPTO_OPENSSL then it just doesn’t work while building.
Please help me to solve this issue
Thank you